Make WordPress Core


Ignore:
Timestamp:
09/03/2024 06:17:19 PM (6 weeks ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

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

    r58025 r58975  
    17581758            if ( is_admin() && $allowed_themes[ $blog_id ] ) {
    17591759                if ( $current ) {
    1760                     update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
     1760                    update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false );
    17611761                    delete_option( 'allowed_themes' );
    17621762                } else {
    17631763                    switch_to_blog( $blog_id );
    1764                     update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
     1764                    update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false );
    17651765                    delete_option( 'allowed_themes' );
    17661766                    restore_current_blog();
Note: See TracChangeset for help on using the changeset viewer.