File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 paths :
1010 - .github/workflows/copilot-setup-steps.yml
1111
12+ permissions :
13+ contents : read
14+
1215jobs :
1316 copilot-setup-steps :
17+ name : Setup environment
1418 runs-on : ubuntu-latest
1519 permissions :
1620 contents : read
1721
1822 steps :
1923 - name : Checkout code
2024 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
25+ with :
26+ persist-credentials : false
2127
2228 - name : Check existence of composer.json file
2329 id : check_composer_file
2430 run : echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2531
2632 - name : Set up PHP environment
2733 if : steps.check_composer_file.outputs.files_exists == 'true'
28- uses : shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
34+ uses : shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2
2935 with :
3036 php-version : ' latest'
3137 ini-values : zend.assertions=1, error_reporting=-1, display_errors=On
3642
3743 - name : Install Composer dependencies & cache dependencies
3844 if : steps.check_composer_file.outputs.files_exists == 'true'
39- uses : ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
45+ uses : ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4046 env :
4147 COMPOSER_ROOT_VERSION : dev-${{ github.event.repository.default_branch }}
Original file line number Diff line number Diff line change @@ -147,3 +147,16 @@ Feature: Export a WordPress database
147147
148148 When I try `wp db export --no-defaults --debug`
149149 Then STDERR should match #Debug \(db\): Running initial shell command: /usr/bin/env (mysqldump|mariadb-dump) --no-defaults#
150+
151+ @skip-sqlite
152+ @skip-windows
153+ Scenario : Export database when PHP exec() is disabled
154+ Given a WP install
155+
156+ When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export wp_cli_test.sql --porcelain`
157+ Then the return code should be 0
158+ And STDOUT should contain:
159+ """
160+ wp_cli_test.sql
161+ """
162+ And the wp_cli_test.sql file should exist
Original file line number Diff line number Diff line change 11<?php
22
33use WP_CLI \Formatter ;
4+ use WP_CLI \Process ;
45use WP_CLI \Utils ;
56use cli \table \Column ;
67use WP_CLI \Db \DB_Command_SQLite ;
@@ -746,7 +747,7 @@ public function export( $args, $assoc_args ) {
746747
747748 $ mysqldump_binary = Utils \force_env_on_nix_systems ( Utils \get_sql_dump_command () );
748749
749- $ support_column_statistics = exec ( $ mysqldump_binary . ' --help | grep " column-statistics" ' );
750+ $ support_column_statistics = $ this -> command_supports_option ( $ mysqldump_binary, ' column-statistics ' );
750751
751752 /*
752753 * In case that `--default-character-set` is not given and `DB_CHARSET` is `utf8`,
@@ -858,6 +859,19 @@ private function get_posts_table_charset( $assoc_args ) {
858859 return $ stdout ;
859860 }
860861
862+ /**
863+ * Check whether a shell command advertises support for a specific option in `--help`.
864+ *
865+ * @param string $command Base shell command to inspect.
866+ * @param string $option Option name to look for.
867+ * @return bool Whether the option is listed in help output.
868+ */
869+ private function command_supports_option ( $ command , $ option ) {
870+ $ result = Process ::create ( "{$ command } --help " )->run ();
871+
872+ return false !== strpos ( $ result ->stdout . $ result ->stderr , $ option );
873+ }
874+
861875 /**
862876 * Imports a database from a file or from STDIN.
863877 *
You can’t perform that action at this time.
0 commit comments