Make WordPress Core


Ignore:
Timestamp:
09/28/2022 01:42:12 PM (2 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r54267 r54345  
    164164        // Prevent non-existent options from triggering multiple queries.
    165165        $notoptions = wp_cache_get( 'notoptions', 'options' );
     166
     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        }
    166172
    167173        if ( isset( $notoptions[ $option ] ) ) {
Note: See TracChangeset for help on using the changeset viewer.