pantheon-systems / wp-redis

WordPress Object Cache using Redis.
https://wordpress.org/plugins/wp-redis/
GNU General Public License v2.0
226 stars 68 forks source link

Remaining Keys Ordering Issue #293

Closed stavultras closed 4 years ago

stavultras commented 4 years ago

I found a small issue (for me it was a big issue) with $remaining_keys ordering when Internal Cache is used. It causes random returns for keys vs $results array: Sometimes

$remaining_keys = array_diff( $keys, array_keys( $cache ) );

can have the first index as 1, but $results array always starts from 0. It causes keys vs results descrepancies here:

foreach ( $remaining_keys as $i => $key ) {
    $value = isset( $results[ $i ] ) ? $results[ $i ] : false;

Eventually

$this->_set_internal( $key, $group, $value );

has the wrong data, because the first $value is $results[1] instead of $results[0], the second $value is $results[2] instead of $results[1] and so on.

The original issue: https://wordpress.org/support/topic/does-not-work-in-wordpress-5-5-thumbnails-2 The CR: https://github.com/pantheon-systems/wp-redis/pull/292