Skip to content

Commit 13a4d4a

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@58975 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d525818 commit 13a4d4a

24 files changed

Lines changed: 66 additions & 34 deletions

src/wp-admin/admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
if ( get_option( 'db_upgraded' ) ) {
3939

4040
flush_rewrite_rules();
41-
update_option( 'db_upgraded', false );
41+
update_option( 'db_upgraded', false, true );
4242

4343
/**
4444
* Fires on the next page load after a successful DB upgrade.

src/wp-admin/includes/class-wp-plugins-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function prepare_items() {
194194
if ( $screen->in_admin( 'network' ) ) {
195195
update_site_option( 'recently_activated', $recently_activated );
196196
} else {
197-
update_option( 'recently_activated', $recently_activated );
197+
update_option( 'recently_activated', $recently_activated, false );
198198
}
199199

200200
$plugin_info = get_site_transient( 'update_plugins' );

src/wp-admin/includes/class-wp-privacy-policy-content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static function text_change_check() {
120120

121121
// Cache the result for use before `admin_init` (see above).
122122
if ( $cached !== $state ) {
123-
update_option( '_wp_suggested_policy_text_has_changed', $state );
123+
update_option( '_wp_suggested_policy_text_has_changed', $state, false );
124124
}
125125

126126
return 'changed' === $state;

src/wp-admin/includes/class-wp-upgrader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ public static function create_lock( $lock_name, $release_timeout = null ) {
10531053
}
10541054

10551055
// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
1056-
update_option( $lock_option, time() );
1056+
update_option( $lock_option, time(), false );
10571057

10581058
return true;
10591059
}

src/wp-admin/includes/dashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
12791279
}
12801280
}
12811281

1282-
update_option( 'dashboard_widget_options', $widget_options );
1282+
update_option( 'dashboard_widget_options', $widget_options, false );
12831283

12841284
$locale = get_user_locale();
12851285
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );

src/wp-admin/includes/file.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2472,7 +2472,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
24722472
);
24732473

24742474
if ( ! wp_installing() ) {
2475-
update_option( 'ftp_credentials', $stored_credentials );
2475+
update_option( 'ftp_credentials', $stored_credentials, false );
24762476
}
24772477

24782478
return $credentials;

src/wp-admin/includes/misc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ function update_option_new_admin_email( $old_value, $value ) {
14771477
'hash' => $hash,
14781478
'newemail' => $value,
14791479
);
1480-
update_option( 'adminhash', $new_admin_email );
1480+
update_option( 'adminhash', $new_admin_email, false );
14811481

14821482
$switched_locale = switch_to_user_locale( get_current_user_id() );
14831483

src/wp-admin/includes/nav-menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
14841484
wp_get_nav_menus( array( 'fields' => 'ids' ) )
14851485
);
14861486

1487-
update_option( 'nav_menu_options', $nav_menu_option );
1487+
update_option( 'nav_menu_options', $nav_menu_option, false );
14881488

14891489
wp_defer_term_counting( false );
14901490

src/wp-admin/includes/plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ function deactivated_plugins_notice() {
26102610

26112611
if ( false === $blog_deactivated_plugins ) {
26122612
// Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
2613-
update_option( 'wp_force_deactivated_plugins', array() );
2613+
update_option( 'wp_force_deactivated_plugins', array(), false );
26142614
}
26152615

26162616
if ( is_multisite() ) {
@@ -2664,7 +2664,7 @@ function deactivated_plugins_notice() {
26642664
}
26652665

26662666
// Empty the options.
2667-
update_option( 'wp_force_deactivated_plugins', array() );
2667+
update_option( 'wp_force_deactivated_plugins', array(), false );
26682668
if ( is_multisite() ) {
26692669
update_site_option( 'wp_force_deactivated_plugins', array() );
26702670
}

src/wp-admin/includes/update-core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ function _upgrade_core_deactivate_incompatible_plugins() {
17631763
} else {
17641764
$deactivated_plugins = get_option( 'wp_force_deactivated_plugins', array() );
17651765
$deactivated_plugins = array_merge( $deactivated_plugins, $deactivated_gutenberg );
1766-
update_option( 'wp_force_deactivated_plugins', $deactivated_plugins );
1766+
update_option( 'wp_force_deactivated_plugins', $deactivated_plugins, false );
17671767
}
17681768
deactivate_plugins( array( 'gutenberg/gutenberg.php' ), true );
17691769
}

0 commit comments

Comments
 (0)