}
if ( $wgLocalMessageCacheSerialized ) {
+ // Check to see if the file has the hash specified
+ $localHash = fread( $file, 32 );
+ if ( $hash === $localHash ) {
+ // All good, get the rest of it
+ $serialized = '';
+ while ( !feof( $file ) ) {
+ $serialized .= fread( $file, 100000 );
+ }
+ $this->setCache( unserialize( $serialized ) );
+ }
+ fclose( $file );
+ } else {
$localHash=substr(fread($file,40),8);
fclose($file);
if ($hash!=$localHash) {
require("$wgLocalMessageCache/messages-" . wfWikiID());
$this->setCache( $this->mCache);
- } else {
- // Check to see if the file has the hash specified
- $localHash = fread( $file, 32 );
- if ( $hash === $localHash ) {
- // All good, get the rest of it
- $serialized = fread( $file, 20000000 );
- $this->setCache( unserialize( $serialized ) );
- }
- fclose( $file );
}
}
}
function loadFromScript( $hash ) {
- trigger_error( 'Use of ' . __METHOD__ . ' is deprecated', E_USER_NOTICE );
+ wfDeprecated( __METHOD__ );
$this->loadFromLocal( $hash );
}
wfProfileIn( __METHOD__ );
$this->lock();
$this->load();
- $parserMemc->delete(wfMemcKey('sidebar'));
if ( is_array( $this->mCache ) ) {
if ( $text === false ) {
# Article was deleted
}
}
$this->unlock();
+ $parserMemc->delete(wfMemcKey('sidebar'));
wfProfileOut( __METHOD__ );
}
}
/**
- * Get the extension messages for a specific language
+ * Get the extension messages for a specific language. Only English, interface
+ * and content language are guaranteed to be loaded.
*
* @param string $lang The messages language, English by default
*/
* Load messages from a given file
*/
function loadMessagesFile( $filename ) {
+ global $wgLang, $wgContLang;
$messages = $magicWords = false;
require( $filename );
- if ( $messages !== false ) {
- $this->addMessagesByLang( $messages );
+ /*
+ * Load only languages that are usually used, and merge all fallbacks,
+ * except English.
+ */
+ $langs = array_unique( array( 'en', $wgContLang->getCode(), $wgLang->getCode() ) );
+ foreach( $langs as $code ) {
+ $fbcode = $code;
+ $mergedMessages = array();
+ do {
+ if ( isset($messages[$fbcode]) ) {
+ $mergedMessages += $messages[$fbcode];
+ }
+ $fbcode = Language::getFallbackfor( $fbcode );
+ } while( $fbcode && $fbcode !== 'en' );
+
+ if ( !empty($mergedMessages) )
+ $this->addMessages( $mergedMessages, $code );
}
if ( $magicWords !== false ) {