Skip to content

Commit 9f0cb87

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54345 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 63d2516 commit 9f0cb87

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wp-includes/option.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ function get_option( $option, $default = false ) {
164164
// Prevent non-existent options from triggering multiple queries.
165165
$notoptions = wp_cache_get( 'notoptions', 'options' );
166166

167+
// Prevent non-existent `notoptions` key from triggering multiple key lookups.
168+
if ( ! is_array( $notoptions ) ) {
169+
$notoptions = array();
170+
wp_cache_set( 'notoptions', $notoptions, 'options' );
171+
}
172+
167173
if ( isset( $notoptions[ $option ] ) ) {
168174
/**
169175
* Filters the default value for an option.

0 commit comments

Comments
 (0)