[wp-trac] [WordPress Trac] #61467: Inconsistent cache handling for network (site) meta

WordPress Trac noreply at wordpress.org
Wed Jun 19 12:56:17 UTC 2024


#61467: Inconsistent cache handling for network (site) meta
------------------------------------+-----------------------------
 Reporter:  xParham                 |      Owner:  (none)
     Type:  defect (bug)            |     Status:  new
 Priority:  normal                  |  Milestone:  Awaiting Review
Component:  Cache API               |    Version:
 Severity:  major                   |   Keywords:
  Focuses:  multisite, performance  |
------------------------------------+-----------------------------
 It appears that there are multiple ways to work with `wp_sitemeta` and
 each use different cache keys and groups, resulting in inconsistent
 behavior and out-of-sync cached values.

 One method is using `update_site_option()`/`update_network_option()` which
 uses `"$network_id:$option"` for the cache key, and `site-options` for the
 group.

 The other method is `update_metadata( 'site', ... )` which uses the object
 ID (here the network ID) for the cache key, and `site_meta` for the cache
 group.

 Normally, in the code, we use
 `update_site_option()`/`update_network_option()`, however, WP CLI's `wp
 network meta ...` uses the `*_metadata()` functions, and when using both
 we end up with out of sync cached values.

 Steps to reproduce the issue via WP CLI:

 {{{
 wp eval 'update_network_option( 1, "mykey", "123" );'
 wp eval 'echo get_network_option( 1, "mykey" );' #Displays 123

 wp network meta update 1 mykey 456
 wp network meta get 1 mykey #Displays 456

 wp eval 'echo get_network_option( 1, "mykey" );' #Still displays 123, but
 456 is the expected value
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61467>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list