Upgrade/Install: Only check plugins whose data is already stored.

In [57592], some `update_option()` calls were removed from bootstrapping. However, this also removed a check to ensure an array key existed, and populated it if not.

Scaffolding tests by WP-CLI revealed that a plugin in the `active_plugins` option may not have data already stored within the `plugin_data` option, causing a PHP warning for an undefined array key. This data will be added the next time `get_plugins()` is called.

This adds a condition to ensure the requirements checks are only performed on plugins whose data is already stored in the `plugin_data` option.

Follow-up to [57592].

Props swissspidy, hellofromTonya, costdev.
Fixes #60461.

git-svn-id: https://develop.svn.wordpress.org/trunk@57622 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Colin Stewart 2024-02-13 13:28:06 +00:00
parent b27b23858f
commit 1d4eff1303

View File

@ -504,6 +504,16 @@ $failed_plugins = array();
$plugins_dir_strlen = strlen( trailingslashit( WP_PLUGIN_DIR ) );
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
$plugin_file = substr( $plugin, $plugins_dir_strlen );
/*
* Skip any plugins that have not been added to the 'plugin_data' option yet.
*
* Some plugin files may be added locally and activated, but will not yet be
* added to the 'plugin_data' option. This causes the 'active_plugins' option
* and the 'plugin_data' option to be temporarily out of sync until the next
* call to `get_plugins()`.
*/
if ( isset( $all_plugin_data[ $plugin_file ] ) ) {
$plugin_headers = $all_plugin_data[ $plugin_file ];
$errors = array();
$requirements = array(
@ -566,6 +576,7 @@ foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
}
continue;
}
}
wp_register_plugin_realpath( $plugin );