diff options
author | Derick Alangi <alangiderick@gmail.com> | 2024-03-21 22:06:32 +0300 |
---|---|---|
committer | Gergő Tisza <tgr.huwiki@gmail.com> | 2024-03-28 19:47:44 +0100 |
commit | e0c34987ebda782445814c5cdf4954fc3b66a5c9 (patch) | |
tree | 57d11760c27270514cdee00be7d42ffdfb992419 /tests/phpunit/includes/objectcache/ObjectCacheTest.php | |
parent | 0ec86c1fb078d2c7ce02adc578f36399ae17d3e4 (diff) | |
download | mediawikicore-e0c34987ebda782445814c5cdf4954fc3b66a5c9.tar.gz mediawikicore-e0c34987ebda782445814c5cdf4954fc3b66a5c9.zip |
objectcache: Restore default keyspace for LocalServerCache service
* Fix main makeLocalServerCache() call in ObjectCacheFactory::newFromId
to include a default keyspace, since wgCachePrefix is false by default
(including at WMF).
* Idem for ExtensionRegistry.
* Dependency inject the domain ID so that service wiring does the
correct thing when doing cross-wiki operations.
This is a followup on: I3179a387486377c6a575d173f39f82870c49c321.
Bug: T358346
Bug: T361177
Change-Id: Ibbb250465529810b8593f90bbb8330af0a2c3dbd
Diffstat (limited to 'tests/phpunit/includes/objectcache/ObjectCacheTest.php')
-rw-r--r-- | tests/phpunit/includes/objectcache/ObjectCacheTest.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/phpunit/includes/objectcache/ObjectCacheTest.php b/tests/phpunit/includes/objectcache/ObjectCacheTest.php index dcaa5c5600aa..1a3358814140 100644 --- a/tests/phpunit/includes/objectcache/ObjectCacheTest.php +++ b/tests/phpunit/includes/objectcache/ObjectCacheTest.php @@ -1,6 +1,8 @@ <?php use MediaWiki\MainConfigNames; +use Wikimedia\Rdbms\DatabaseDomain; +use Wikimedia\TestingAccessWrapper; /** * @covers \ObjectCache @@ -104,6 +106,37 @@ class ObjectCacheTest extends MediaWikiIntegrationTestCase { ); } + public function provideLocalServerKeyspace() { + $dbDomain = static function ( $dbName, $dbPrefix ) { + global $wgDBmwschema; + return ( new DatabaseDomain( $dbName, $wgDBmwschema, $dbPrefix ) )->getId(); + }; + return [ + 'default' => [ false, 'my_wiki', '', $dbDomain( 'my_wiki', '' ) ], + 'custom' => [ 'custom', 'my_wiki', '', 'custom' ], + 'prefix' => [ false, 'my_wiki', 'nl_', $dbDomain( 'my_wiki', 'nl_' ) ], + 'empty string' => [ '', 'my_wiki', 'nl_', $dbDomain( 'my_wiki', 'nl_' ) ], + ]; + } + + /** + * @dataProvider provideLocalServerKeyspace + * @covers \ObjectCache + * @covers \ObjectCacheFactory + * @covers \MediaWiki\WikiMap\WikiMap + */ + public function testLocalServerKeyspace( $cachePrefix, $dbName, $dbPrefix, $expect ) { + $this->overrideConfigValues( [ + MainConfigNames::CachePrefix => $cachePrefix, + MainConfigNames::DBname => $dbName, + MainConfigNames::DBprefix => $dbPrefix, + ] ); + // Regression against T247562 (2020), T361177 (2024). + $cache = $this->getServiceContainer()->getObjectCacheFactory()->getInstance( CACHE_ACCEL ); + $cache = TestingAccessWrapper::newFromObject( $cache ); + $this->assertSame( $expect, $cache->keyspace ); + } + public static function provideIsDatabaseId() { return [ [ CACHE_DB, CACHE_NONE, true ], |