mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-30 15:31:04 +01:00
Options, Meta APIs: Prime notoptions
cache when deleting options.
Prime the `notoptions` cache within `delete_option` and `delete_network_option` to avoid the need for a database query if `get_option` or `get_network_option` is subsequently called. Adds some associated tests to ensure that an option is cleared from the notoptions cache when an option is added either via `add_option`, `update_option` or their network option equivalent. Props pbearne, mukesh27. Fixes #61484. Built from https://develop.svn.wordpress.org/trunk@58782 git-svn-id: http://core.svn.wordpress.org/trunk@58184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8529edd888
commit
2ecc281f69
@ -1217,6 +1217,15 @@ function delete_option( $option ) {
|
||||
} else {
|
||||
wp_cache_delete( $option, 'options' );
|
||||
}
|
||||
|
||||
$notoptions = wp_cache_get( 'notoptions', 'options' );
|
||||
|
||||
if ( ! is_array( $notoptions ) ) {
|
||||
$notoptions = array();
|
||||
}
|
||||
$notoptions[ $option ] = true;
|
||||
|
||||
wp_cache_set( 'notoptions', $notoptions, 'options' );
|
||||
}
|
||||
|
||||
if ( $result ) {
|
||||
@ -2284,6 +2293,15 @@ function delete_network_option( $network_id, $option ) {
|
||||
*/
|
||||
do_action( 'delete_site_option', $option, $network_id );
|
||||
|
||||
$notoptions_key = "$network_id:notoptions";
|
||||
$notoptions = wp_cache_get( $notoptions_key, 'site-options' );
|
||||
|
||||
if ( ! is_array( $notoptions ) ) {
|
||||
$notoptions = array();
|
||||
}
|
||||
$notoptions[ $option ] = true;
|
||||
wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-58781';
|
||||
$wp_version = '6.7-alpha-58782';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user