[wp-trac] [WordPress Trac] #18955: get_site_option caches default value when option does not exist

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 15 10:09:19 UTC 2011


#18955: get_site_option caches default value when option does not exist
--------------------------+------------------------------
 Reporter:  wpmuguru      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Multisite     |     Version:  3.2.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------
Changes (by duck_):

 * keywords:   => has-patch


Old description:

> If get_site_option is passed any default value on a non-existent site
> option then a subsequent call to update_site_option will not add the site
> option. Because the site option does not exist, it does not get updated
> either. To reproduce
>
> - in the sitemeta table edit the active_sitewide_plugins meta_key to be
> active_sitewide_plugins_x
> - go to the network plugins screen and network activate any plugin
>
> You get the message that the plugin was activated, but it doesn't because
> the site option doesn't get saved.
>
> Options for fixing
>
> 1- change the get_site_option in update_site_options to not use cache
> 2- add a notsiteoption cache and cache the non-existence of the site
> option
> 3- don't cache the default value in get_site_option
>
> Option 1 is quick & easy
> Option 2 is more work but the way the blog options are handled and it
> would make things more consistent
> Option 3 is probably not the preferable solution

New description:

 If get_site_option is passed any default value on a non-existent site
 option then a subsequent call to update_site_option will not add the site
 option. Because the site option does not exist, it does not get updated
 either. To reproduce

 - in the sitemeta table edit the active_sitewide_plugins meta_key to be
 active_sitewide_plugins_x
 - go to the network plugins screen and network activate any plugin

 You get the message that the plugin was activated, but it doesn't because
 the site option doesn't get saved.

 Options for fixing

  1. change the get_site_option in update_site_options to not use cache
  2. add a notsiteoption cache and cache the non-existence of the site
 option
  3. don't cache the default value in get_site_option

 Option 1 is quick & easy
 Option 2 is more work but the way the blog options are handled and it
 would make things more consistent
 Option 3 is probably not the preferable solution

--

Comment:

 As noted by your steps this bug requires code to ignore the site_option
 API to be triggered (so the DB and cache aren't in sync) and shouldn't
 happen in core.

 Attached 18955.notoptions.diff example patch for adding a notoptions cache
 for site-options. I think this is the most sensible option. I'd say that 1
 was the least preferable.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18955#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list