#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: |
|
Owned by: |
|
---|---|---|---|
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
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
@
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.
#5
@
7 months ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from new to closed
In 58811:
@peterwilsoncc commented on PR #7074:
7 months ago
#6
Merged r58811 / https://github.com/WordPress/wordpress-develop/commit/b38541de39c5e3ccb75ff76b49ab930846c878b6
Thanks for catching this, Brad, it's much appreciated.
On a non-multisite,
get_network_option()
,add_network_option()
, andupdate_network_option()
don't bother updating the networknotoptions
cache, instead reling onget_option()
,add_option()
, andupdate_option()
to use the non-networknotoptions
.delete_options()
anddelete_network_options()
were recently updated to populate thenotoptions
caches. But, contrary to existing practice,delete_network_options()
was made to update the networknotoptions
cache even on non-multisites.This moves the updating of the network
notoptions
cache indelete_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