When JSON support was introduced into ParserCache in 1.36, it was controlled by a feature flag, $wgParserCacheUseJson. The feature flag was "born deprecated" in 1.36. It can now be removed. This means that ParserCache will always store entries as JSON. Support for reading old non-JSON entries remains intact. This is needed when updating wikis from a version older than 1.36 to the current version. Change-Id: Id04e42bfb458d98414bac50e0d6c505e8878e5c0
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Config\ServiceOptions;
|
|
use MediaWiki\Json\JsonCodec;
|
|
use MediaWiki\Page\WikiPageFactory;
|
|
use MediaWiki\Parser\ParserCacheFactory;
|
|
use MediaWiki\Parser\RevisionOutputCache;
|
|
use Psr\Log\NullLogger;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Parser\ParserCacheFactory
|
|
*/
|
|
class ParserCacheFactoryTest extends MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @return ParserCacheFactory
|
|
*/
|
|
private function newParserCacheFactory() {
|
|
$options = new ServiceOptions( ParserCacheFactory::CONSTRUCTOR_OPTIONS, [
|
|
'CacheEpoch' => '20200202112233',
|
|
'OldRevisionParserCacheExpireTime' => 60,
|
|
] );
|
|
|
|
return new ParserCacheFactory(
|
|
new HashBagOStuff(),
|
|
new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ),
|
|
$this->createHookContainer(),
|
|
new JsonCodec(),
|
|
new NullStatsdDataFactory(),
|
|
new NullLogger(),
|
|
$options,
|
|
$this->createNoOpMock( TitleFactory::class ),
|
|
$this->createNoOpMock( WikiPageFactory::class )
|
|
);
|
|
}
|
|
|
|
public function testGetParserCache() {
|
|
$factory = $this->newParserCacheFactory();
|
|
|
|
$a = $factory->getParserCache( 'test' );
|
|
$this->assertInstanceOf( ParserCache::class, $a );
|
|
|
|
$b = $factory->getParserCache( 'test' );
|
|
$this->assertSame( $a, $b );
|
|
|
|
$c = $factory->getParserCache( 'xyzzy' );
|
|
$this->assertNotSame( $a, $c );
|
|
}
|
|
|
|
public function testGetRevisionOutputCache() {
|
|
$factory = $this->newParserCacheFactory();
|
|
|
|
$a = $factory->getRevisionOutputCache( 'test' );
|
|
$this->assertInstanceOf( RevisionOutputCache::class, $a );
|
|
|
|
$b = $factory->getRevisionOutputCache( 'test' );
|
|
$this->assertSame( $a, $b );
|
|
|
|
$c = $factory->getRevisionOutputCache( 'xyzzy' );
|
|
$this->assertNotSame( $a, $c );
|
|
}
|
|
|
|
}
|