Make WordPress Core

Opened 6 years ago

Last modified 4 years ago

#43598 reviewing enhancement

site-options notoption only queried and never set in not multisite wordpress installs

Reported by: grzegorzjanoszka's profile Grzegorz.Janoszka Owned by: sergeybiryukov's profile 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)

43598.diff (2.3 KB) - added by soulseekah 6 years ago.

Download all attachments as: .zip

Change History (8)

@soulseekah
6 years ago

#1 @soulseekah
6 years ago

  • Keywords has-patch dev-feedback added

Hey, welcome back @Grzegorz.Janoszka!

Thank you for your ticket!

get_network_option is an alias for get_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 a is_multisite() condition which prevents the $network_id:notoptions logic, directs the call to plain old get_options which stores non-existing options in the plain old notoptions 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 the wp_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 :)

#2 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 5.0
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @SergeyBiryukov
5 years ago

  • Milestone changed from 5.0 to 5.1

#4 @pento
5 years ago

  • Milestone changed from 5.1 to 5.2

#5 @desrosj
5 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.

#6 @davidbaumwald
4 years ago

@SergeyBiryukov Can you review this one and decide whether it's ready for version 5.3 Beta 1, due out tomorrow? If not, we can punt this to a future milestone.

#7 @davidbaumwald
4 years ago

  • Milestone changed from 5.3 to Future Release

This ticket has not received any attention during the 5.3 cycle. With 5.3 Beta 1 now releasing, the deadline for enhancements is passed. I'm moving this to Future Release.

Note: See TracTickets for help on using tickets.