Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#61730 closed defect (bug) (fixed)

`delete_network_option` sets network `notoptions` cache on non-multisites, but `add_network_option` and `update_network_option` do not clear it

Reported by: bjorsch's profile bjorsch Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 6.7 Priority: normal
Severity: normal Version: 6.7
Component: Options, Meta APIs Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

On a non-multisite, get_network_option(), add_network_option(), and update_network_option() don't bother updating the network notoptions cache, instead reling on get_option(), add_option(), and update_option() to use the non-network notoptions.

r58782 had delete_network_option() start updating the network notoptions cache even on non-multisites, which breaks the other functions since they do check this otherwise-unused-on-non-multisites cache.

Testing using wp shell:

wp> add_network_option( 1, 'some-option', 'xyz' );
=> bool(true)
wp> delete_network_option( 1, 'some-option' );
=> bool(true)
wp> wp_cache_get( '1:notoptions', 'site-options' );
=> array(1) {
  ["some-option"]=>
  bool(true)
}
wp> add_network_option( 1, 'some-option', 'abc' );
=> bool(true)
wp> wp_cache_get( '1:notoptions', 'site-options' );
=> array(1) {
  ["some-option"]=>
  bool(true)
}
wp> get_network_option( 1, 'some-option' );
=> bool(false)

Change History (6)

This ticket was mentioned in PR #7074 on WordPress/wordpress-develop by @bjorsch.


7 months ago
#1

  • Keywords has-patch has-unit-tests added

On a non-multisite, get_network_option(), add_network_option(), and update_network_option() don't bother updating the network notoptions cache, instead reling on get_option(), add_option(), and update_option() to use the non-network notoptions.

delete_options() and delete_network_options() were recently updated to populate the notoptions caches. But, contrary to existing practice, delete_network_options() was made to update the network notoptions cache even on non-multisites.

This moves the updating of the network notoptions cache in delete_network_options() to the multisite code path, matching the behavior of the other functions, and adds a test to verify this.

Trac ticket: https://core.trac.wordpress.org/ticket/61730

@bjorsch commented on PR #7074:


7 months ago
#2

An alternative fix would be to update the other functions to all populate the network notoptions cache, but this seemed more straightforward.

#3 @peterwilsoncc
7 months ago

  • Milestone changed from Awaiting Review to 6.7

Thanks for the report @bjorsch, I've moved this on to the 6.7 milestone.

I'll review your pull request an take a look at the differences between how the various network options behave on single site installations.

#4 @pbearne
7 months ago

This looks like a good change to the 61484 patch

#5 @peterwilsoncc
7 months ago

  • Owner set to peterwilsoncc
  • Resolution set to fixed
  • Status changed from new to closed

In 58811:

Options, Meta APIs: Prevent Single Site installs using network notoptions cache.

Modifies the caching of notoptions in delete_network_option() to ensure that the network cache is bypassed on single site installs.

On single site installs the incorrect caching was causing the notoptions cache to remain populated once a deleted option was subsequently added or updated.

Follow up to [58782].

Props bjorsch, pbearne.
Fixes #61730.
See #61484.

Note: See TracTickets for help on using tickets.