* @ingroup Cache
*/
use MediaWiki\MediaWikiServices;
+use Wikimedia\ScopedCallback;
/**
* MediaWiki message cache structure version.
* or false if populating empty cache fails. Also returns true if MessageCache
* is disabled.
*
- * @param bool|string $code Language to which load messages
- * @param integer $mode Use MessageCache::FOR_UPDATE to skip process cache
+ * @param string $code Language to which load messages
+ * @param integer $mode Use MessageCache::FOR_UPDATE to skip process cache [optional]
* @throws MWException
* @return bool
*/
- function load( $code = false, $mode = null ) {
+ protected function load( $code, $mode = null ) {
if ( !is_string( $code ) ) {
- # This isn't really nice, so at least make a note about it and try to
- # fall back
- wfDebug( __METHOD__ . " called without providing a language code\n" );
- $code = 'en';
+ throw new InvalidArgumentException( "Missing language code" );
}
# Don't do double loading...
if ( $dest === 'all' ) {
$cacheKey = wfMemcKey( 'messages', $code );
$success = $this->mMemc->set( $cacheKey, $cache );
+ $this->setValidationHash( $code, $cache );
} else {
$success = true;
}
- $this->setValidationHash( $code, $cache );
$this->saveToLocalCache( $code, $cache );
return $success;
}
$alreadyTried[ $langcode ] = true;
}
+ } else {
+ $uckey = null;
}
// Check the CDB cache
continue;
}
- $message = $this->getMsgFromNamespace( $this->getMessagePageName( $code, $uckey ), $code );
+ $message = $this->getMsgFromNamespace(
+ $this->getMessagePageName( $code, $uckey ), $code );
if ( $message !== false ) {
return $message;