From 5414aee495e6469f949d744c97c12baf0948ea2a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 16 Feb 2019 19:44:36 -0800 Subject: [PATCH] objectcache: remove dangling WAN cache EventRelayer references * Remove 'channels' field references from config/setup * Remove 'relayer'/'channels' field reference in unit tests * Remove unused DEFAULT_PURGE_CHANNEL class constant * Also remove long-since bogus 'pool' field references Follow-up to 4753b0a4ed4b6b8abb Change-Id: If6670ff4e1dccc8ae253a08b46d205601da10024 --- includes/DefaultSettings.php | 11 ++--- includes/Setup.php | 3 +- includes/libs/objectcache/WANObjectCache.php | 2 - .../libs/objectcache/WANObjectCacheReaper.php | 1 - .../libs/objectcache/WANObjectCacheTest.php | 41 ++++--------------- 5 files changed, 14 insertions(+), 44 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index dc8f1e86e4..537f411cb4 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2456,23 +2456,20 @@ $wgMainWANCache = false; * * The format is an associative array where the key is a cache identifier, and * the value is an associative array of parameters. The "cacheId" parameter is - * a cache identifier from $wgObjectCaches. The "channels" parameter is a map of - * actions ('purge') to PubSub channels defined in $wgEventRelayerConfig. - * The "loggroup" parameter controls where log events are sent. + * a cache identifier from $wgObjectCaches. The "loggroup" parameter controls + * where log events are sent. * * @since 1.26 */ $wgWANObjectCaches = [ CACHE_NONE => [ 'class' => WANObjectCache::class, - 'cacheId' => CACHE_NONE, - 'channels' => [] + 'cacheId' => CACHE_NONE ] /* Example of a simple single data-center cache: 'memcached-php' => [ 'class' => WANObjectCache::class, - 'cacheId' => 'memcached-php', - 'channels' => [ 'purge' => 'wancache-main-memcached-purge' ] + 'cacheId' => 'memcached-php' ] */ ]; diff --git a/includes/Setup.php b/includes/Setup.php index b4b6ce6e9c..f8b9546442 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -690,8 +690,7 @@ if ( $wgMainWANCache === false ) { $wgMainWANCache = 'mediawiki-main-default'; $wgWANObjectCaches[$wgMainWANCache] = [ 'class' => WANObjectCache::class, - 'cacheId' => $wgMainCacheType, - 'channels' => [ 'purge' => 'wancache-main-default-purge' ] + 'cacheId' => $wgMainCacheType ]; } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index f9debafaa6..2329140f9c 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -221,8 +221,6 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { const PC_PRIMARY = 'primary:1000'; // process cache name and max key count - const DEFAULT_PURGE_CHANNEL = 'wancache-purge'; - /** * @param array $params * - cache : BagOStuff object for a persistent cache diff --git a/includes/libs/objectcache/WANObjectCacheReaper.php b/includes/libs/objectcache/WANObjectCacheReaper.php index e4ab95c936..fb8a75469e 100644 --- a/includes/libs/objectcache/WANObjectCacheReaper.php +++ b/includes/libs/objectcache/WANObjectCacheReaper.php @@ -69,7 +69,6 @@ class WANObjectCacheReaper implements LoggerAwareInterface { * The callback must fully duck-type test the object, since can be any model class. * @param array $params Additional options: * - channel: the name of the update event stream. - * Default: WANObjectCache::DEFAULT_PURGE_CHANNEL. * - initialStartWindow: seconds back in time to start if the position is lost. * Default: 1 hour. * - logger: an SPL monolog instance [optional] diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index 369b2bfc06..d9b7e18bdf 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -30,9 +30,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { parent::setUp(); $this->cache = new WANObjectCache( [ - 'cache' => new HashBagOStuff(), - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) + 'cache' => new HashBagOStuff() ] ); $wanCache = TestingAccessWrapper::newFromObject( $this->cache ); @@ -440,8 +438,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { }; $cache = new NearExpiringWANObjectCache( [ - 'cache' => new HashBagOStuff(), - 'pool' => 'empty', + 'cache' => new HashBagOStuff() ] ); $wasSet = 0; @@ -468,7 +465,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { }; $cache = new NearExpiringWANObjectCache( [ 'cache' => new HashBagOStuff(), - 'pool' => 'empty', 'asyncHandler' => $asyncHandler ] ); @@ -500,8 +496,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $this->assertEquals( $value, $v, "New value stored" ); $cache = new PopularityRefreshingWANObjectCache( [ - 'cache' => new HashBagOStuff(), - 'pool' => 'empty' + 'cache' => new HashBagOStuff() ] ); $mockWallClock = $priorTime; @@ -694,7 +689,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { WANObjectCache::VALUE_KEY_PREFIX . 'k1' => 'val-id1', WANObjectCache::VALUE_KEY_PREFIX . 'k2' => 'val-id2' ] ); - $wanCache = new WANObjectCache( [ 'cache' => $localBag, 'pool' => 'testcache-hash' ] ); + $wanCache = new WANObjectCache( [ 'cache' => $localBag ] ); // Warm the process cache $keyedIds = new ArrayIterator( [ 'k1' => 'id1', 'k2' => 'id2' ] ); @@ -1504,9 +1499,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { ->willReturn( false ); $wanCache = new WANObjectCache( [ - 'cache' => $backend, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) + 'cache' => $backend ] ); $isStale = null; @@ -1556,8 +1549,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $localBag->expects( $this->never() )->method( 'delete' ); $wanCache = new WANObjectCache( [ 'cache' => $localBag, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ), 'mcrouterAware' => true, 'region' => 'pmtpa', 'cluster' => 'mw-wan' @@ -1582,8 +1573,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { ->setMethods( [ 'set' ] )->getMock(); $wanCache = new WANObjectCache( [ 'cache' => $localBag, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ), 'mcrouterAware' => true, 'region' => 'pmtpa', 'cluster' => 'mw-wan' @@ -1600,8 +1589,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { ->setMethods( [ 'set' ] )->getMock(); $wanCache = new WANObjectCache( [ 'cache' => $localBag, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ), 'mcrouterAware' => true, 'region' => 'pmtpa', 'cluster' => 'mw-wan' @@ -1618,8 +1605,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { ->setMethods( [ 'delete' ] )->getMock(); $wanCache = new WANObjectCache( [ 'cache' => $localBag, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ), 'mcrouterAware' => true, 'region' => 'pmtpa', 'cluster' => 'mw-wan' @@ -1633,7 +1618,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { public function testEpoch() { $bag = new HashBagOStuff(); - $cache = new WANObjectCache( [ 'cache' => $bag, 'pool' => 'testcache-hash' ] ); + $cache = new WANObjectCache( [ 'cache' => $bag ] ); $key = $cache->makeGlobalKey( 'The whole of the Law' ); $now = microtime( true ); @@ -1649,7 +1634,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $cache = new WANObjectCache( [ 'cache' => $bag, - 'pool' => 'testcache-hash', 'epoch' => $now - 3600 ] ); $cache->setMockTime( $now ); @@ -1660,7 +1644,6 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { $now += 30; $cache = new WANObjectCache( [ 'cache' => $bag, - 'pool' => 'testcache-hash', 'epoch' => $now + 3600 ] ); $cache->setMockTime( $now ); @@ -1746,9 +1729,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { ->willReturn( 'special' ); $wanCache = new WANObjectCache( [ - 'cache' => $backend, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) + 'cache' => $backend ] ); $this->assertSame( 'special', $wanCache->makeKey( 'a', 'b' ) ); @@ -1764,9 +1745,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { ->willReturn( 'special' ); $wanCache = new WANObjectCache( [ - 'cache' => $backend, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) + 'cache' => $backend ] ); $this->assertSame( 'special', $wanCache->makeGlobalKey( 'a', 'b' ) ); @@ -1787,9 +1766,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { */ public function testStatsKeyClass( $key, $class ) { $wanCache = TestingAccessWrapper::newFromObject( new WANObjectCache( [ - 'cache' => new HashBagOStuff, - 'pool' => 'testcache-hash', - 'relayer' => new EventRelayerNull( [] ) + 'cache' => new HashBagOStuff ] ) ); $this->assertEquals( $class, $wanCache->determineKeyClass( $key ) ); -- 2.20.1