Make WordPress Core


Ignore:
Timestamp:
02/12/2024 12:31:29 PM (15 months ago)
Author:
costdev
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r57545 r57592  
    987987    $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
    988988
    989     $invalid_plugins = array();
    990989    foreach ( $active_plugins as $plugin ) {
    991990        if ( ! validate_file( $plugin )                     // $plugin must validate as file.
     
    996995        ) {
    997996            $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
    998         } else {
    999             $invalid_plugins[] = $plugin;
    1000         }
    1001     }
    1002 
    1003     if ( ! empty( $invalid_plugins ) ) {
    1004         $all_plugin_data = get_option( 'plugin_data', array() );
    1005 
    1006         if ( ! empty( $all_plugin_data ) ) {
    1007             foreach ( $invalid_plugins as $invalid_plugin ) {
    1008                 unset( $all_plugin_data[ $invalid_plugin ] );
    1009             }
    1010 
    1011             update_option( 'plugin_data', $all_plugin_data );
    1012997        }
    1013998    }
Note: See TracChangeset for help on using the changeset viewer.