From: Aaron Schulz Date: Wed, 15 Jun 2016 16:40:34 +0000 (-0700) Subject: Fix WAN cache stashing bug due to missing list() call X-Git-Tag: 1.31.0-rc.0~6601 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=fd4940a1b6120142d353f3e4e4062c5df1518a15;p=lhc%2Fweb%2Fwiklou.git Fix WAN cache stashing bug due to missing list() call Fixes regression from 0a38dbc809. Bug: T137877 Change-Id: I4ea960966c084ada36dc54d4ec8729126c17ccdc --- diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 45713cc814..ab702d57be 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -902,7 +902,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { // For hot keys, either another thread has the lock or the lock failed; // use the INTERIM value from the last thread that regenerated it. $wrapped = $this->cache->get( self::INTERIM_KEY_PREFIX . $key ); - $value = $this->unwrap( $wrapped, microtime( true ) ); + list( $value ) = $this->unwrap( $wrapped, microtime( true ) ); if ( $value !== false && $this->isValid( $value, $versioned, $asOf, $minTime ) ) { $asOf = $wrapped[self::FLD_TIME]; diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index 3a4aab487f..5bc1c8dbea 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -217,9 +217,23 @@ class WANObjectCacheTest extends MediaWikiTestCase { // Acquire a lock to verify that getWithSetCallback uses lockTSE properly $this->internalCache->lock( $key, 0 ); - $ret = $cache->getWithSetCallback( $key, 30, $func, [ 'lockTSE' => 5 ] ); + + $checkKeys = [ wfRandomString() ]; // new check keys => force misses + $ret = $cache->getWithSetCallback( $key, 30, $func, + [ 'lockTSE' => 5, 'checkKeys' => $checkKeys ] ); $this->assertEquals( $value, $ret ); $this->assertEquals( 1, $calls, 'Callback was not used' ); + + $cache->delete( $key ); + $ret = $cache->getWithSetCallback( $key, 30, $func, + [ 'lockTSE' => 5, 'checkKeys' => $checkKeys ] ); // should use interim value + $this->assertEquals( $value, $ret ); + $this->assertEquals( 2, $calls, 'Callback was used' ); + + $ret = $cache->getWithSetCallback( $key, 30, $func, + [ 'lockTSE' => 5, 'checkKeys' => $checkKeys ] ); + $this->assertEquals( $value, $ret ); + $this->assertEquals( 2, $calls, 'Callback was not used; used interim' ); } /**