*/
protected $cache;
+ /**
+ * Map of (lowercase message key => index) for all software defined messages
+ *
+ * @var array
+ */
+ protected $overridable;
+
/**
* @var bool[] Map of (language code => boolean)
*/
return true;
}
+ $this->overridable = array_flip( Language::getMessageKeysFor( $code ) );
+
# 8 lines of code just to say (once) that message cache is disabled
if ( $this->mDisable ) {
static $shownDisabled = false;
$this->cache->getField( $code, 'HASH' )
);
} else {
- // Message page does not exist or does not override a software message.
- // Load the message page, utilizing the individual message cache.
- $entry = $this->loadCachedMessagePageEntry(
- $title,
- $code,
- $this->cache->getField( $code, 'HASH' )
- );
- if ( substr( $entry, 0, 1 ) !== ' ' ) {
+ // Message page either does not exist or does not override a software message
+ if ( !isset( $this->overridable[$this->contLang->lcfirst( $title )] ) ) {
+ // Message page does not override any software-defined message. A custom
+ // message might be defined to have content or settings specific to the wiki.
+ // Load the message page, utilizing the individual message cache as needed.
+ $entry = $this->loadCachedMessagePageEntry(
+ $title,
+ $code,
+ $this->cache->getField( $code, 'HASH' )
+ );
+ }
+ if ( $entry === null || substr( $entry, 0, 1 ) !== ' ' ) {
// Message does not have a MediaWiki page definition; try hook handlers
$message = false;
Hooks::run( 'MessagesPreLoad', [ $title, &$message, $code ] );
[ 'ćaB', 'ćaB' ],
];
}
+
+ public function testNoDBAccess() {
+ global $wgContLanguageCode;
+
+ $dbr = wfGetDB( DB_REPLICA );
+
+ MessageCache::singleton()->getMsgFromNamespace( 'allpages', $wgContLanguageCode );
+
+ $this->assertEquals( 0, $dbr->trxLevel() );
+ $dbr->setFlag( DBO_TRX, $dbr::REMEMBER_PRIOR ); // make queries trigger TRX
+
+ MessageCache::singleton()->getMsgFromNamespace( 'go', $wgContLanguageCode );
+
+ $dbr->restoreFlags();
+
+ $this->assertEquals( 0, $dbr->trxLevel(), "No DB read queries" );
+ }
}