mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user