wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Fatal error: Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, bool given (class-wp-upgrader.php:603)

drzraf opened this issue · comments

Bug Report

Describe the current, buggy behavior

PHP Fatal error:  Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, bool given in /srv/www/xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php:603](http://xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php:603)
Stack trace:
#0 /srv/www/[xxx/web/wp/wp-admin/includes/class-wp-upgrader.php(603)](http://xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php(603)): array_keys()
#1 /srv/www/[xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php(876)](http://xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php(876)): WP_Upgrader->install_package()
#2 /srv/www/[xxx.com/web/wp/wp-admin/includes/class-plugin-upgrader.php(380)](http://xxx.com/web/wp/wp-admin/includes/class-plugin-upgrader.php(380)): WP_Upgrader->run()
#3 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php(439): Plugin_Upgrader->bulk_upgrade()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/Plugin_Command.php(687): WP_CLI\CommandWithUpgrade->update_many()
#5 [internal function]: Plugin_Command->update()
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func()
#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(431): WP_CLI\Dispatcher\Subcommand->invoke()
#10 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(454): WP_CLI\Runner->run_command()
#11 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1269): WP_CLI\Runner->run_command_and_exit()
#12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process()
#14 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#15 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('...')
#16 /usr/local/bin/wp(4): include('...')
#17 {main}
  thrown in /srv/www/xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php](http://xxx.com/web/wp/wp-admin/includes/class-wp-upgrader.php) on line 603

Describe how other contributors can replicate this bug

  • wp plugin update --all --patch --quiet --no-color

Describe what you would expect as the correct outcome

A clear error message

Let us know what environment you are running this on

WP 6.4.1, WP-cli 2.8.1, Debian 12, php 8.2

Provide a possible solution

Seems it happened just once probably due to a specific plugin messing up with repository's version/URL/.... One among these:

advanced-custom-fields-pro	active	available	6.2.4
comment-moderation-e-mail-to-post-author	active	none	0.6
dearflip	active	none	1.7.35
enable-media-replace	active	none	4.1.5
wp-maintenance-mode	active	none	2.6.10
openid-connect-generic	active	none	3.9.1
wp-search-with-algolia	active	available	2.7.1
duplicate-post	active	none	4.5

class-wp-upgrader.php is a file in WordPress core, so this is not really an issue with WP-CLI.

These types of issues are usually caused by premium plugins messing with upgrades.

In this case here, the $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); line could use some hardening, as dirlist can indeed return false.

I suggest opening an enhancement ticket on Trac to add some hardening there.

Closing this one because, again, this is not an issue in WP-CLI.