* @ingroup Cache
*/
class MessageCache {
+ const FOR_UPDATE = 1; // force message reload
+
/**
* Process local cache of loaded messages that are defined in
* MediaWiki namespace. First array level is a language code,
* is disabled.
*
* @param bool|string $code Language to which load messages
+ * @param integer $mode Use MessageCache::FOR_UPDATE to skip process cache
* @throws MWException
* @return bool
*/
- function load( $code = false ) {
+ function load( $code = false, $mode = null ) {
global $wgUseLocalMessageCache;
if ( !is_string( $code ) ) {
}
# Don't do double loading...
- if ( isset( $this->mLoadedLanguages[$code] ) ) {
+ if ( isset( $this->mLoadedLanguages[$code] ) && $mode != self::FOR_UPDATE ) {
return true;
}
# Hash of the contents is stored in memcache, to detect if local cache goes
# out of date (e.g. due to replace() on some other server)
if ( $wgUseLocalMessageCache ) {
-
$hash = $this->mMemc->get( wfMemcKey( 'messages', $code, 'hash' ) );
if ( $hash ) {
$cache = $this->getLocalCache( $hash, $code );
*/
function loadFromDB( $code ) {
global $wgMaxMsgCacheEntrySize, $wgLanguageCode, $wgAdaptiveMessageCache;
+
$dbr = wfGetDB( DB_SLAVE );
$cache = array();
* @param mixed $text New contents of the page.
*/
public function replace( $title, $text ) {
- global $wgMaxMsgCacheEntrySize;
+ global $wgMaxMsgCacheEntrySize, $wgContLang;
if ( $this->mDisable ) {
-
return;
}
list( $msg, $code ) = $this->figureMessage( $title );
$cacheKey = wfMemcKey( 'messages', $code );
- $this->load( $code );
$this->lock( $cacheKey );
+ $this->load( $code, self::FOR_UPDATE );
$titleKey = wfMemcKey( 'messages', 'individual', $title );
}
// Update the message in the message blob store
- global $wgContLang;
$blobStore = new MessageBlobStore();
$blobStore->updateMessage( $wgContLang->lcfirst( $msg ) );
$this->makePage( 'MessageCacheTest-FullKeyTest', 'ru' );
// In content language -- get base if no derivative
- $this->makePage( 'FallbackLanguageTest-NoDervContLang', 'de', 'de/none', false );
+ $this->makePage( 'FallbackLanguageTest-NoDervContLang', 'de', 'de/none' );
}
/**
* @param string $title Title of page to be created
* @param string $lang Language and content of the created page
* @param string|null $content Content of the created page, or null for a generic string
- * @param bool $createSubPage Set to false if a root page should be created
*/
- protected function makePage( $title, $lang, $content = null, $createSubPage = true ) {
+ protected function makePage( $title, $lang, $content = null ) {
global $wgContLang;
if ( $content === null ) {
$content = $lang;
}
- if ( $lang !== $wgContLang->getCode() || $createSubPage ) {
+ if ( $lang !== $wgContLang->getCode() ) {
$title = "$title/$lang";
}