Options, Meta APIs: Explicitly pass `$autoload` parameter to when potentially adding new options.
It is recommended that for every option it is explicitly set whether to autoload it or not. This changeset updates relevant `update_option()` and `add_option()` calls. Note that the `$autoload` parameter is only needed for `update_option()` if the option is potentially not present yet, i.e. the call will pass through to `add_option()`. Since WordPress core adds the majority of its options to the database during installation, only `update_option()` calls for dynamically added options need to be modified, which is what this changeset does. As part of revisiting the autoload values for dynamically added WordPress core options, this changeset modifies some options to no longer be autoloaded, since they are only accessed in a few specific places that are not relevant for a regular request. These options are: * `recently_activated` * `_wp_suggested_policy_text_has_changed` * `{upgradeLock}.lock` * `dashboard_widget_options` * `ftp_credentials` * `adminhash` * `nav_menu_options` * `wp_force_deactivated_plugins` * `delete_blog_hash` * `allowedthemes` * `{sessionId}_paused_extensions` * `recovery_keys` * `https_detection_errors` * `fresh_site` An upgrade routine is present as well that sets those options to no longer autoload for existing sites. Props pbearne, flixos90, mukesh27, swissspidy, SergeyBiryukov, joemcgill, adamsilverstein. Fixes #61103. Built from https://develop.svn.wordpress.org/trunk@58975 git-svn-id: http://core.svn.wordpress.org/trunk@58371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
77af97466f
commit
4e167c593d
|
@ -38,7 +38,7 @@ nocache_headers();
|
|||
if ( get_option( 'db_upgraded' ) ) {
|
||||
|
||||
flush_rewrite_rules();
|
||||
update_option( 'db_upgraded', false );
|
||||
update_option( 'db_upgraded', false, true );
|
||||
|
||||
/**
|
||||
* Fires on the next page load after a successful DB upgrade.
|
||||
|
|
|
@ -194,7 +194,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
if ( $screen->in_admin( 'network' ) ) {
|
||||
update_site_option( 'recently_activated', $recently_activated );
|
||||
} else {
|
||||
update_option( 'recently_activated', $recently_activated );
|
||||
update_option( 'recently_activated', $recently_activated, false );
|
||||
}
|
||||
|
||||
$plugin_info = get_site_transient( 'update_plugins' );
|
||||
|
|
|
@ -120,7 +120,7 @@ final class WP_Privacy_Policy_Content {
|
|||
|
||||
// Cache the result for use before `admin_init` (see above).
|
||||
if ( $cached !== $state ) {
|
||||
update_option( '_wp_suggested_policy_text_has_changed', $state );
|
||||
update_option( '_wp_suggested_policy_text_has_changed', $state, false );
|
||||
}
|
||||
|
||||
return 'changed' === $state;
|
||||
|
|
|
@ -1053,7 +1053,7 @@ class WP_Upgrader {
|
|||
}
|
||||
|
||||
// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
|
||||
update_option( $lock_option, time() );
|
||||
update_option( $lock_option, time(), false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1279,7 +1279,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
|
|||
}
|
||||
}
|
||||
|
||||
update_option( 'dashboard_widget_options', $widget_options );
|
||||
update_option( 'dashboard_widget_options', $widget_options, false );
|
||||
|
||||
$locale = get_user_locale();
|
||||
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
|
||||
|
|
|
@ -2472,7 +2472,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
|
|||
);
|
||||
|
||||
if ( ! wp_installing() ) {
|
||||
update_option( 'ftp_credentials', $stored_credentials );
|
||||
update_option( 'ftp_credentials', $stored_credentials, false );
|
||||
}
|
||||
|
||||
return $credentials;
|
||||
|
|
|
@ -1477,7 +1477,7 @@ function update_option_new_admin_email( $old_value, $value ) {
|
|||
'hash' => $hash,
|
||||
'newemail' => $value,
|
||||
);
|
||||
update_option( 'adminhash', $new_admin_email );
|
||||
update_option( 'adminhash', $new_admin_email, false );
|
||||
|
||||
$switched_locale = switch_to_user_locale( get_current_user_id() );
|
||||
|
||||
|
|
|
@ -1484,7 +1484,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
|||
wp_get_nav_menus( array( 'fields' => 'ids' ) )
|
||||
);
|
||||
|
||||
update_option( 'nav_menu_options', $nav_menu_option );
|
||||
update_option( 'nav_menu_options', $nav_menu_option, false );
|
||||
|
||||
wp_defer_term_counting( false );
|
||||
|
||||
|
|
|
@ -2610,7 +2610,7 @@ function deactivated_plugins_notice() {
|
|||
|
||||
if ( false === $blog_deactivated_plugins ) {
|
||||
// Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
|
||||
update_option( 'wp_force_deactivated_plugins', array() );
|
||||
update_option( 'wp_force_deactivated_plugins', array(), false );
|
||||
}
|
||||
|
||||
if ( is_multisite() ) {
|
||||
|
@ -2664,7 +2664,7 @@ function deactivated_plugins_notice() {
|
|||
}
|
||||
|
||||
// Empty the options.
|
||||
update_option( 'wp_force_deactivated_plugins', array() );
|
||||
update_option( 'wp_force_deactivated_plugins', array(), false );
|
||||
if ( is_multisite() ) {
|
||||
update_site_option( 'wp_force_deactivated_plugins', array() );
|
||||
}
|
||||
|
|
|
@ -1763,7 +1763,7 @@ function _upgrade_core_deactivate_incompatible_plugins() {
|
|||
} else {
|
||||
$deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
|
||||
$deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
|
||||
update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
|
||||
update_option( 'wp_force_deactivated_plugins', $deactivated_plugins, false );
|
||||
}
|
||||
deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ if ( ! function_exists( 'wp_install' ) ) :
|
|||
update_option( 'blog_public', $is_public );
|
||||
|
||||
// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
|
||||
update_option( 'fresh_site', 1 );
|
||||
update_option( 'fresh_site', 1, false );
|
||||
|
||||
if ( $language ) {
|
||||
update_option( 'WPLANG', $language );
|
||||
|
@ -863,6 +863,9 @@ function upgrade_all() {
|
|||
upgrade_650();
|
||||
}
|
||||
|
||||
if ( $wp_current_db_version < 58975 ) {
|
||||
upgrade_670();
|
||||
}
|
||||
maybe_disable_link_manager();
|
||||
|
||||
maybe_disable_automattic_widgets();
|
||||
|
@ -2397,7 +2400,36 @@ function upgrade_650() {
|
|||
wp_set_option_autoload_values( $autoload );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Executes changes made in WordPress 6.7.0.
|
||||
*
|
||||
* @ignore
|
||||
* @since 6.7.0
|
||||
*
|
||||
* @global int $wp_current_db_version The old (current) database version.
|
||||
*/
|
||||
function upgrade_670() {
|
||||
global $wp_current_db_version;
|
||||
|
||||
if ( $wp_current_db_version < 58975 ) {
|
||||
$options = array(
|
||||
'recently_activated',
|
||||
'_wp_suggested_policy_text_has_changed',
|
||||
'dashboard_widget_options',
|
||||
'ftp_credentials',
|
||||
'adminhash',
|
||||
'nav_menu_options',
|
||||
'wp_force_deactivated_plugins',
|
||||
'delete_blog_hash',
|
||||
'allowedthemes',
|
||||
'recovery_keys',
|
||||
'https_detection_errors',
|
||||
'fresh_site',
|
||||
);
|
||||
|
||||
wp_set_options_autoload( $options, false );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Executes network-level upgrade routines.
|
||||
*
|
||||
|
|
|
@ -48,7 +48,7 @@ if ( isset( $_POST['action'] ) && 'deleteblog' === $_POST['action'] && isset( $_
|
|||
check_admin_referer( 'delete-blog' );
|
||||
|
||||
$hash = wp_generate_password( 20, false );
|
||||
update_option( 'delete_blog_hash', $hash );
|
||||
update_option( 'delete_blog_hash', $hash, false );
|
||||
|
||||
$url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) );
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ if ( $action ) {
|
|||
}
|
||||
}
|
||||
|
||||
update_option( 'allowedthemes', $allowed_themes );
|
||||
update_option( 'allowedthemes', $allowed_themes, false );
|
||||
restore_current_blog();
|
||||
|
||||
wp_safe_redirect(
|
||||
|
|
|
@ -71,7 +71,7 @@ if ( $action ) {
|
|||
if ( ! is_network_admin() ) {
|
||||
$recent = (array) get_option( 'recently_activated' );
|
||||
unset( $recent[ $plugin ] );
|
||||
update_option( 'recently_activated', $recent );
|
||||
update_option( 'recently_activated', $recent, false );
|
||||
} else {
|
||||
$recent = (array) get_site_option( 'recently_activated' );
|
||||
unset( $recent[ $plugin ] );
|
||||
|
@ -136,7 +136,7 @@ if ( $action ) {
|
|||
}
|
||||
|
||||
if ( ! is_network_admin() ) {
|
||||
update_option( 'recently_activated', $recent );
|
||||
update_option( 'recently_activated', $recent, false );
|
||||
} else {
|
||||
update_site_option( 'recently_activated', $recent );
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ if ( $action ) {
|
|||
deactivate_plugins( $plugin, false, is_network_admin() );
|
||||
|
||||
if ( ! is_network_admin() ) {
|
||||
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
|
||||
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ), false );
|
||||
} else {
|
||||
update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ if ( $action ) {
|
|||
}
|
||||
|
||||
if ( ! is_network_admin() ) {
|
||||
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
|
||||
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ), false );
|
||||
} else {
|
||||
update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ if ( $action ) {
|
|||
exit;
|
||||
case 'clear-recent-list':
|
||||
if ( ! is_network_admin() ) {
|
||||
update_option( 'recently_activated', array() );
|
||||
update_option( 'recently_activated', array(), false );
|
||||
} else {
|
||||
update_site_option( 'recently_activated', array() );
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class WP_Paused_Extensions_Storage {
|
|||
|
||||
$paused_extensions[ $this->type ][ $extension ] = $error;
|
||||
|
||||
return update_option( $option_name, $paused_extensions );
|
||||
return update_option( $option_name, $paused_extensions, false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ class WP_Paused_Extensions_Storage {
|
|||
return delete_option( $option_name );
|
||||
}
|
||||
|
||||
return update_option( $option_name, $paused_extensions );
|
||||
return update_option( $option_name, $paused_extensions, false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,7 +190,7 @@ class WP_Paused_Extensions_Storage {
|
|||
return delete_option( $option_name );
|
||||
}
|
||||
|
||||
return update_option( $option_name, $paused_extensions );
|
||||
return update_option( $option_name, $paused_extensions, false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -187,6 +187,6 @@ final class WP_Recovery_Mode_Key_Service {
|
|||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
private function update_keys( array $keys ) {
|
||||
return update_option( $this->option_name, $keys );
|
||||
return update_option( $this->option_name, $keys, false );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ class WP_Roles {
|
|||
'capabilities' => $capabilities,
|
||||
);
|
||||
if ( $this->use_db ) {
|
||||
update_option( $this->role_key, $this->roles );
|
||||
update_option( $this->role_key, $this->roles, true );
|
||||
}
|
||||
$this->role_objects[ $role ] = new WP_Role( $role, $capabilities );
|
||||
$this->role_names[ $role ] = $display_name;
|
||||
|
|
|
@ -1757,11 +1757,11 @@ final class WP_Theme implements ArrayAccess {
|
|||
// Set the option so we never have to go through this pain again.
|
||||
if ( is_admin() && $allowed_themes[ $blog_id ] ) {
|
||||
if ( $current ) {
|
||||
update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
|
||||
update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false );
|
||||
delete_option( 'allowed_themes' );
|
||||
} else {
|
||||
switch_to_blog( $blog_id );
|
||||
update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
|
||||
update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false );
|
||||
delete_option( 'allowed_themes' );
|
||||
restore_current_blog();
|
||||
}
|
||||
|
|
|
@ -1240,7 +1240,7 @@ function _set_cron_array( $cron, $wp_error = false ) {
|
|||
|
||||
$cron['version'] = 2;
|
||||
|
||||
$result = update_option( 'cron', $cron );
|
||||
$result = update_option( 'cron', $cron, true );
|
||||
|
||||
if ( $wp_error && ! $result ) {
|
||||
return new WP_Error(
|
||||
|
@ -1280,7 +1280,7 @@ function _upgrade_cron_array( $cron ) {
|
|||
|
||||
$new_cron['version'] = 2;
|
||||
|
||||
update_option( 'cron', $new_cron );
|
||||
update_option( 'cron', $new_cron, true );
|
||||
|
||||
return $new_cron;
|
||||
}
|
||||
|
|
|
@ -6002,7 +6002,7 @@ function wp_update_https_detection_errors() {
|
|||
*/
|
||||
$support_errors = apply_filters( 'pre_wp_update_https_detection_errors', null );
|
||||
if ( is_wp_error( $support_errors ) ) {
|
||||
update_option( 'https_detection_errors', $support_errors->errors );
|
||||
update_option( 'https_detection_errors', $support_errors->errors, false );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4705,7 +4705,7 @@ function _config_wp_siteurl( $url = '' ) {
|
|||
* @access private
|
||||
*/
|
||||
function _delete_option_fresh_site() {
|
||||
update_option( 'fresh_site', '0' );
|
||||
update_option( 'fresh_site', '0', false );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2021,7 +2021,7 @@ function check_upload_mimes( $mimes ) {
|
|||
*/
|
||||
function update_posts_count( $deprecated = '' ) {
|
||||
global $wpdb;
|
||||
update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
|
||||
update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -786,7 +786,7 @@ function switch_theme( $stylesheet ) {
|
|||
}
|
||||
|
||||
$nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
|
||||
update_option( 'theme_switch_menu_locations', $nav_menu_locations );
|
||||
update_option( 'theme_switch_menu_locations', $nav_menu_locations, true );
|
||||
|
||||
if ( func_num_args() > 1 ) {
|
||||
$stylesheet = func_get_arg( 1 );
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-58974';
|
||||
$wp_version = '6.7-alpha-58975';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
*
|
||||
* @global int $wp_db_version
|
||||
*/
|
||||
$wp_db_version = 57155;
|
||||
$wp_db_version = 58975;
|
||||
|
||||
/**
|
||||
* Holds the TinyMCE version.
|
||||
|
|
Loading…
Reference in New Issue