X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FMessageCache.php;h=8b52728e0382d8cdbc208b5f29eea6500e7331f7;hb=f90977bcc58fd88a806a50ca2d3faad0ee2dab2e;hp=a92c87f481e447df8238064c8f493b08b8655a97;hpb=7ab94d37bb200481a929edd03f6cf3279efbf224;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index a92c87f481..8b52728e03 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -110,6 +110,7 @@ class MessageCache { $wgMsgCacheExpiry ); } + return self::$instance; } @@ -147,6 +148,7 @@ class MessageCache { $this->mParserOptions = new ParserOptions; $this->mParserOptions->setEditSection( false ); } + return $this->mParserOptions; } @@ -179,9 +181,11 @@ class MessageCache { $serialized .= fread( $file, 100000 ); } fclose( $file ); + return unserialize( $serialized ); } else { fclose( $file ); + return false; // Wrong hash } } @@ -201,6 +205,7 @@ class MessageCache { if ( !$file ) { wfDebug( "Unable to open local cache file for writing\n" ); + return; } @@ -253,6 +258,7 @@ class MessageCache { wfDebug( __METHOD__ . ": disabled\n" ); $shownDisabled = true; } + return true; } @@ -415,6 +421,7 @@ class MessageCache { $info = implode( ', ', $where ); wfDebug( __METHOD__ . ": Loading $code... $info\n" ); wfProfileOut( __METHOD__ ); + return $success; } @@ -502,6 +509,7 @@ class MessageCache { $cache['VERSION'] = MSG_CACHE_VERSION; $cache['EXPIRY'] = wfTimestamp( TS_MW, time() + $this->mExpiry ); wfProfileOut( __METHOD__ ); + return $cache; } @@ -517,6 +525,7 @@ class MessageCache { if ( $this->mDisable ) { wfProfileOut( __METHOD__ ); + return; } @@ -584,6 +593,7 @@ class MessageCache { if ( wfTimestampNow() >= $cache['EXPIRY'] ) { return true; } + return false; } @@ -617,6 +627,7 @@ class MessageCache { } wfProfileOut( __METHOD__ ); + return $success; } @@ -689,7 +700,8 @@ class MessageCache { * "msg/lang". * * @throws MWException when given an invalid key - * @return string|bool False if the message doesn't exist, otherwise the message (which can be empty) + * @return string|bool False if the message doesn't exist, otherwise the + * message (which can be empty) */ function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) { global $wgContLang; @@ -726,7 +738,12 @@ class MessageCache { // Loop through each language in the fallback list until we find something useful $lang = wfGetLangObj( $langcode ); - $message = $this->getMessageFromFallbackChain( $lang, $lckey, $uckey, !$this->mDisable && $useDB ); + $message = $this->getMessageFromFallbackChain( + $lang, + $lckey, + $uckey, + !$this->mDisable && $useDB + ); // If we still have no message, maybe the key was in fact a full key so try that if ( $message === false ) { @@ -804,7 +821,8 @@ class MessageCache { return $message; } - list( $fallbackChain, $siteFallbackChain ) = Language::getFallbacksIncludingSiteLanguage( $langcode ); + list( $fallbackChain, $siteFallbackChain ) = + Language::getFallbacksIncludingSiteLanguage( $langcode ); // Next try checking the database for all of the fallback languages of the requested language. if ( $useDB ) { @@ -897,11 +915,13 @@ class MessageCache { if ( $entry ) { if ( substr( $entry, 0, 1 ) === ' ' ) { $this->mCache[$code][$title] = $entry; + // The message exists, so make sure a string // is returned. return (string)substr( $entry, 1 ); } elseif ( $entry === '!NONEXISTENT' ) { $this->mCache[$code][$title] = '!NONEXISTENT'; + return false; } else { # Corrupt/obsolete entry, delete it @@ -983,6 +1003,7 @@ class MessageCache { $this->mInParser = false; $popts->setUserLang( $userlang ); } + return $message; } @@ -1003,6 +1024,7 @@ class MessageCache { $this->mParser = clone $wgParser; } } + return $this->mParser; } @@ -1043,6 +1065,7 @@ class MessageCache { $this->mInParser = false; wfProfileOut( __METHOD__ ); + return $res; } @@ -1085,6 +1108,7 @@ class MessageCache { } $message = implode( '/', $pieces ); + return array( $message, $lang ); } @@ -1109,6 +1133,7 @@ class MessageCache { unset( $cache['EXPIRY'] ); // Remove any !NONEXISTENT keys $cache = array_diff( $cache, array( '!NONEXISTENT' ) ); + // Keys may appear with a capital first letter. lcfirst them. return array_map( array( $wgContLang, 'lcfirst' ), array_keys( $cache ) ); }