From b456ae75fba6ef6bd5892bcd977d005009029aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Thu, 8 Sep 2016 12:44:24 +0200 Subject: [PATCH] Fix strict standard error about variable reference When ran the command `wp core language update` I got the following error : ``` PHP Strict standards: Only variables should be passed by reference in /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithTranslation.php on line 169 PHP Stack trace: PHP 1. {main}() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/boot-fs.php:0 PHP 2. include() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/boot-fs.php:17 PHP 3. WP_CLI\Runner->start() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/wp-cli.php:21 PHP 4. WP_CLI\Runner->_run_command() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:906 PHP 5. WP_CLI\Runner->run_command() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:319 PHP 6. WP_CLI\Dispatcher\Subcommand->invoke() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:312 PHP 7. call_user_func:{/Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:372}() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:372 PHP 8. WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:372 PHP 9. call_user_func:{/Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:67}() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:67 PHP 10. WP_CLI\CommandWithTranslation->update() /Users/shulard/Sites/Clients/Cher Ami/schneider-life-is-on/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:67 ``` It's about the `array_shift` call on the `get_plugins` function result directly. This commit fix that by introducing a transition variable. --- php/WP_CLI/CommandWithTranslation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php/WP_CLI/CommandWithTranslation.php b/php/WP_CLI/CommandWithTranslation.php index dbd2ffb4a2..cba6ec7571 100644 --- a/php/WP_CLI/CommandWithTranslation.php +++ b/php/WP_CLI/CommandWithTranslation.php @@ -192,7 +192,8 @@ public function update( $args, $assoc_args ) { // Formats the updates list. foreach ( $updates as $update ) { if ( 'plugin' == $update->type ) { - $plugin_data = array_shift( get_plugins( '/' . $update->slug ) ); + $plugins = get_plugins( '/' . $update->slug ); + $plugin_data = array_shift( $plugins ); $name = $plugin_data['Name']; } elseif ( 'theme' == $update->type ) { $theme_data = wp_get_theme( $update->slug );