Opened 7 years ago
Last modified 5 years ago
#43598 reviewing enhancement
site-options notoption only queried and never set in not multisite wordpress installs
Reported by: | Grzegorz.Janoszka | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.9.5 |
Component: | Options, Meta APIs | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
We have notoptions mechanism that works well. WordPress core does also query $network_id:notoptions regardless of multiste. However, such option is set only in multisite installs. As a result, if you are not running multisite, you are only querying for $network_id:notoptions and you never set it. It beats the idea of notoptions - we read it, but we never set it - what's the point?
Possible solutions:
- read $network_id:notoptions only in multisite installs
- set $network_id:notoptions also in not multisite installs
Attachments (1)
Change History (8)
#2
@
6 years ago
- Milestone changed from Awaiting Review to 5.0
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#5
@
6 years ago
- Milestone changed from 5.2 to 5.3
This ticket has not received any attention during the 5.2 cycle. With beta 1 tomorrow, going to punt this to 5.3.
Note: See
TracTickets for help on using
tickets.
Hey, welcome back @Grzegorz.Janoszka!
Thank you for your ticket!
get_network_option
is an alias forget_site_option
, which is called in core in many places. In non-multisite installs,$network_id
is set to 1 by default.These calls are absolutely valid, and
$network_id:notoptions
is indeed not being set. There's ais_multisite()
condition which prevents the$network_id:notoptions
logic, directs the call to plain oldget_options
which stores non-existing options in the plain oldnotoptions
cache.In single-site setups the multisite code bits are never called apart from
wp_cache_get
which is deterministic there. It seems safe to omit thewp_cache_get
call since it's never being set to anything useful but called multiple times from core. It does set wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); to an empty array in single-site installs, which is also useless, since it will always remain as such.43599.diff stubs these calls out. Might need unit-tests to make sure that notoptions caching works in multisite mode as it is supposed to, and that it's always empty in single-sites. Or we can risk it :)