Upgrade/Install: Avoid `update_option()` calls during bootstrap.
[57545] introduced the Plugin Dependencies feature, which contains a new `plugin_data` option. Previously, the `plugin_data` option was being updated during bootstrap and in `get_plugins()`, causing an error when using the install script as the options database table does not yet exist, and also risked an "out of sync" issue between the database and the cache on websites with heavy traffic. This removes the calls to `update_option()` during Core's bootstrap, and guards the call in `get_plugins()` to ensure that it doesn't run when WordPress is installing. Follow-up to [57545]. Props desrosj, swisspidy, huzaifaalmesbah, afragen, dd32, azaozz, costdev. Fixes #60461. See #60457, #60491. Built from https://develop.svn.wordpress.org/trunk@57592 git-svn-id: http://core.svn.wordpress.org/trunk@57093 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c309be74be
commit
c04996591b
|
@ -360,7 +360,10 @@ function get_plugins( $plugin_folder = '' ) {
|
|||
|
||||
$cache_plugins[ $plugin_folder ] = $wp_plugins;
|
||||
wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
|
||||
|
||||
if ( ! wp_installing() ) {
|
||||
update_option( 'plugin_data', $new_plugin_data );
|
||||
}
|
||||
|
||||
return $wp_plugins;
|
||||
}
|
||||
|
|
|
@ -986,7 +986,6 @@ function wp_get_active_and_valid_plugins() {
|
|||
|
||||
$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
|
||||
|
||||
$invalid_plugins = array();
|
||||
foreach ( $active_plugins as $plugin ) {
|
||||
if ( ! validate_file( $plugin ) // $plugin must validate as file.
|
||||
&& str_ends_with( $plugin, '.php' ) // $plugin must end with '.php'.
|
||||
|
@ -995,20 +994,6 @@ function wp_get_active_and_valid_plugins() {
|
|||
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) )
|
||||
) {
|
||||
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
|
||||
} else {
|
||||
$invalid_plugins[] = $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $invalid_plugins ) ) {
|
||||
$all_plugin_data = get_option( 'plugin_data', array() );
|
||||
|
||||
if ( ! empty( $all_plugin_data ) ) {
|
||||
foreach ( $invalid_plugins as $invalid_plugin ) {
|
||||
unset( $all_plugin_data[ $invalid_plugin ] );
|
||||
}
|
||||
|
||||
update_option( 'plugin_data', $all_plugin_data );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.5-alpha-57591';
|
||||
$wp_version = '6.5-alpha-57592';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -501,26 +501,16 @@ if ( ! is_multisite() && wp_is_fatal_error_handler_enabled() ) {
|
|||
// Load active plugins.
|
||||
$all_plugin_data = get_option( 'plugin_data', array() );
|
||||
$failed_plugins = array();
|
||||
$update_plugin_data = false;
|
||||
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
|
||||
$plugin_file = str_replace( trailingslashit( WP_PLUGIN_DIR ), '', $plugin );
|
||||
if ( ! isset( $all_plugin_data[ $plugin_file ] ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
$all_plugin_data[ $plugin_file ] = get_plugin_data( WP_PLUGIN_DIR . "/$plugin_file" );
|
||||
|
||||
$update_plugin_data = true;
|
||||
}
|
||||
|
||||
$plugin_headers = $all_plugin_data[ $plugin_file ];
|
||||
$errors = array();
|
||||
$requirements = array(
|
||||
'requires' => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '',
|
||||
'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '',
|
||||
'requires_plugins' => ! empty( $plugin_headers['RequiresPlugins'] ) ? $plugin_headers['RequiresPlugins'] : '',
|
||||
);
|
||||
$compatible_wp = is_wp_version_compatible( $requirements['requires'] );
|
||||
$compatible_php = is_php_version_compatible( $requirements['requires_php'] );
|
||||
$dependencies_met = ! WP_Plugin_Dependencies::has_unmet_dependencies( $plugin_file );
|
||||
|
||||
$php_update_message = '</p><p>' . sprintf(
|
||||
/* translators: %s: URL to Update PHP page. */
|
||||
|
@ -534,14 +524,6 @@ foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
|
|||
$php_update_message .= '</p><p><em>' . $annotation . '</em>';
|
||||
}
|
||||
|
||||
if ( ! $dependencies_met ) {
|
||||
$errors[] = sprintf(
|
||||
/* translators: %s: The plugin's name. */
|
||||
_x( '%s has unmet dependencies.', 'plugin' ),
|
||||
$plugin_headers['Name']
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $compatible_wp && ! $compatible_php ) {
|
||||
$errors[] = sprintf(
|
||||
/* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
|
||||
|
@ -601,10 +583,6 @@ foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
|
|||
}
|
||||
unset( $plugin, $_wp_plugin_file );
|
||||
|
||||
if ( $update_plugin_data ) {
|
||||
update_option( 'plugin_data', $all_plugin_data );
|
||||
}
|
||||
|
||||
if ( ! empty( $failed_plugins ) ) {
|
||||
add_action(
|
||||
'admin_notices',
|
||||
|
|
Loading…
Reference in New Issue