For classes that inherit from MediaWikiTestCase and used setMwGlobals() to
modify a variable that affects namespaces, caches will automatically be
reset and any calls to MWNamespace::clearCaches() can be removed entirely.
+* ReadOnlyMode::clearCache() and ConfiguredReadOnlyMode::clearCache() have been
+ removed. Use MediaWikiTestCase::overrideMwServices() instead.
=== Deprecations in 1.33 ===
* The configuration option $wgUseESI has been deprecated, and is expected
public function setReason( $msg ) {
$this->overrideReason = $msg;
}
-
- /**
- * Clear the cache of the read only file
- */
- public function clearCache() {
- $this->fileReason = null;
- }
}
public function setReason( $msg ) {
$this->configuredReadOnly->setReason( $msg );
}
-
- /**
- * Clear the cache of the read only file
- */
- public function clearCache() {
- $this->configuredReadOnly->clearCache();
- }
}
unlink( $readOnlyFile );
$this->setMwGlobals( [
+ 'wgReadOnly' => null,
'wgReadOnlyFile' => $readOnlyFile,
'wgUrlProtocols' => [
'http://',
* @covers ::wfReadOnly
*/
public function testReadOnlyEmpty() {
- global $wgReadOnly;
- $wgReadOnly = null;
-
- MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()->clearCache();
$this->assertFalse( wfReadOnly() );
$this->assertFalse( wfReadOnly() );
}
* @covers ::wfReadOnly
*/
public function testReadOnlySet() {
- global $wgReadOnly, $wgReadOnlyFile;
-
- $readOnlyMode = MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode();
- $readOnlyMode->clearCache();
+ global $wgReadOnlyFile;
$f = fopen( $wgReadOnlyFile, "wt" );
fwrite( $f, 'Message' );
fclose( $f );
- $wgReadOnly = null; # Check on $wgReadOnlyFile
+
+ // Reset the service to avoid cached results
+ $this->overrideMwServices();
$this->assertTrue( wfReadOnly() );
$this->assertTrue( wfReadOnly() ); # Check cached
-
- unlink( $wgReadOnlyFile );
- $readOnlyMode->clearCache();
- $this->assertFalse( wfReadOnly() );
- $this->assertFalse( wfReadOnly() );
}
/**
*/
public function testReadOnlyGlobalChange() {
$this->assertFalse( wfReadOnlyReason() );
+
$this->setMwGlobals( [
'wgReadOnly' => 'reason'
] );
+ $this->overrideMwServices();
+
$this->assertSame( 'reason', wfReadOnlyReason() );
}
$rom->setReason( 'override' );
$this->assertSame( 'override', $rom->getReason() );
}
-
- /**
- * @covers ReadOnlyMode::clearCache
- * @covers ConfiguredReadOnlyMode::clearCache
- */
- public function testClearCache() {
- $fileName = $this->getNewTempFile();
- unlink( $fileName );
- $config = new HashConfig( [
- 'ReadOnly' => null,
- 'ReadOnlyFile' => $fileName,
- ] );
- $cro = new ConfiguredReadOnlyMode( $config );
- $lb = $this->createLB( [ 'lbMessage' => false ] );
- $rom = new ReadOnlyMode( $cro, $lb );
-
- $this->assertSame( false, $rom->getReason(), 'initial' );
-
- file_put_contents( $fileName, 'file' );
- $this->assertSame( false, $rom->getReason(), 'stale' );
-
- $rom->clearCache();
- $this->assertSame( 'file', $rom->getReason(), 'fresh' );
- }
}