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 @@ -174,3 +174,16 @@ Feature: Export a WordPress database
174174
175175 When I try `wp db export --no-defaults --debug`
176176 Then STDERR should match #Debug \(db\): Running initial shell command: /usr/bin/env (mysqldump|mariadb-dump) --no-defaults#
177+
178+ @skip-sqlite
179+ @skip-windows
180+ Scenario : Export database when PHP exec() is disabled
181+ Given a WP install
182+
183+ When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=exec} db export wp_cli_test.sql --porcelain`
184+ Then the return code should be 0
185+ And STDOUT should contain:
186+ """
187+ wp_cli_test.sql
188+ """
189+ 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 ;
67
@@ -755,7 +756,7 @@ public function export( $args, $assoc_args ) {
755756
756757 $ mysqldump_binary = Utils \force_env_on_nix_systems ( Utils \get_sql_dump_command () );
757758
758- $ support_column_statistics = exec ( $ mysqldump_binary . ' --help | grep " column-statistics" ' );
759+ $ support_column_statistics = $ this -> command_supports_option ( $ mysqldump_binary, ' column-statistics ' );
759760
760761 /*
761762 * In case that `--default-character-set` is not given and `DB_CHARSET` is `utf8`,
@@ -887,6 +888,19 @@ private function get_posts_table_charset( $assoc_args ) {
887888 return $ stdout ;
888889 }
889890
891+ /**
892+ * Check whether a shell command advertises support for a specific option in `--help`.
893+ *
894+ * @param string $command Base shell command to inspect.
895+ * @param string $option Option name to look for.
896+ * @return bool Whether the option is listed in help output.
897+ */
898+ private function command_supports_option ( $ command , $ option ) {
899+ $ result = Process ::create ( "{$ command } --help " )->run ();
900+
901+ return false !== strpos ( $ result ->stdout . $ result ->stderr , $ option );
902+ }
903+
890904 /**
891905 * Imports a database from a file or from STDIN.
892906 *
You can’t perform that action at this time.
0 commit comments