WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#39034 closed defect (bug) (worksforme)

WP_Site_Query->get_sites() constructs an invalid key...

Reported by: seanosh Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: reporter-feedback
Focuses: multisite Cc:
PR Number:

Description

From class-wp-site-query.php starting on line 247 (checked in trunk, 4.6.1):

$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
$last_changed = wp_cache_get_last_changed( 'sites' );

$cache_key = "get_sites:$key:$last_changed";
$cache_value = wp_cache_get( $cache_key, 'sites' );

The resulting $cache_key is something like:
get_sites:cb4b246a2a9b16dca39a573cce210c10:0.89962600 1480710961

For installs that use the memcache/memcached object-cache drop-in (and possibly others), the resulting wp_cache_get always returns false since a memcached key "... must not include control characters or whitespace." (per memcached protocol)

Change History (2)

#1 @jeremyfelt
3 years ago

  • Keywords reporter-feedback added

Hi @seanosh, thanks for opening a ticket.

WordPress has been using microtime() to generate the last changed value for quite a while across several different cache keys.n 4.7, some of this has been combined into the new wp_cache_get_last_changed() function. See #37464.

After some initial testing with memcached 1.4.2, PECL memcached, and PHP 7.0.9 (thanks @johnjamesjacoby), it seems that memcached is able to store and retrieve the cache fine. It may just drop the piece after the space when storing the key.

Can you provide the PHP and memcached versions you are using as well as the drop-in?

#2 @jeremyfelt
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
  • Version 4.7 deleted

I'm going to go ahead and close this out. Please feel free to re-open with new information.

Note: See TracTickets for help on using tickets.