Options, Meta APIs: Prevent excessive notoptions key lookups.

When the `notoptions` key does not exist in a persistent object cache, it was requested hundreds of times until the first not-option is written.

This commit improves performance by setting the value to an empty array to prevent non-existent `notoptions` key from triggering multiple key lookups.

Follow-up to [4855], [14515].

Props tillkruess, dd32, spacedmonkey.
Fixes #56639.
Built from https://develop.svn.wordpress.org/trunk@54345


git-svn-id: http://core.svn.wordpress.org/trunk@53904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-09-28 13:44:15 +00:00
parent 84729259de
commit bb8988e3ec
2 changed files with 7 additions and 1 deletions

View File

@ -164,6 +164,12 @@ function get_option( $option, $default = false ) {
// Prevent non-existent options from triggering multiple queries.
$notoptions = wp_cache_get( 'notoptions', 'options' );
// Prevent non-existent `notoptions` key from triggering multiple key lookups.
if ( ! is_array( $notoptions ) ) {
$notoptions = array();
wp_cache_set( 'notoptions', $notoptions, 'options' );
}
if ( isset( $notoptions[ $option ] ) ) {
/**
* Filters the default value for an option.

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-beta2-54344';
$wp_version = '6.1-beta2-54345';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.