diff options
Diffstat (limited to 'includes/cache/MessageCache.php')
-rw-r--r-- | includes/cache/MessageCache.php | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 146edd28..b854a2ec 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -1,5 +1,22 @@ <?php /** + * Localisation messages cache. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Cache */ @@ -115,6 +132,7 @@ class MessageCache { function getParserOptions() { if ( !$this->mParserOptions ) { $this->mParserOptions = new ParserOptions; + $this->mParserOptions->setEditSection( false ); } return $this->mParserOptions; } @@ -126,7 +144,7 @@ class MessageCache { * * @param $hash String: the hash of contents, to check validity. * @param $code Mixed: Optional language code, see documenation of load(). - * @return false on failure. + * @return bool on failure. */ function loadFromLocal( $hash, $code ) { global $wgCacheDirectory, $wgLocalMessageCacheSerialized; @@ -260,6 +278,7 @@ class MessageCache { * is disabled. * * @param $code String: language to which load messages + * @return bool */ function load( $code = false ) { global $wgUseLocalMessageCache; @@ -496,7 +515,7 @@ class MessageCache { if ( $code === 'en' ) { // Delete all sidebars, like for example on action=purge on the // sidebar messages - $codes = array_keys( Language::getLanguageNames() ); + $codes = array_keys( Language::fetchLanguageNames() ); } global $wgMemc; @@ -520,7 +539,7 @@ class MessageCache { * @param $cache Array: cached messages with a version. * @param $memc Bool: Wether to update or not memcache. * @param $code String: Language code. - * @return False on somekind of error. + * @return bool on somekind of error. */ protected function saveToCaches( $cache, $memc = true, $code = false ) { wfProfileIn( __METHOD__ ); @@ -588,7 +607,7 @@ class MessageCache { * @param $isFullKey Boolean: specifies whether $key is a two part key * "msg/lang". * - * @return string|false + * @return string|bool */ function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) { global $wgLanguageCode, $wgContLang; @@ -696,7 +715,7 @@ class MessageCache { * @param $title String: Message cache key with initial uppercase letter. * @param $code String: code denoting the language to try. * - * @return string|false + * @return string|bool False on failure */ function getMsgFromNamespace( $title, $code ) { global $wgAdaptiveMessageCache; @@ -747,12 +766,14 @@ class MessageCache { } # Try loading it from the database - $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) ); + $revision = Revision::newFromTitle( + Title::makeTitle( NS_MEDIAWIKI, $title ), false, Revision::READ_LATEST + ); if ( $revision ) { $message = $revision->getText(); if ($message === false) { // A possibly temporary loading failure. - wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title->getDbKey()} ($code)" ); + wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title} ($code)" ); } else { $this->mCache[$code][$title] = ' ' . $message; $this->mMemc->set( $titleKey, ' ' . $message, $this->mExpiry ); @@ -868,7 +889,7 @@ class MessageCache { * Clear all stored messages. Mainly used after a mass rebuild. */ function clear() { - $langs = Language::getLanguageNames( false ); + $langs = Language::fetchLanguageNames( null, 'mw' ); foreach ( array_keys($langs) as $code ) { # Global cache $this->mMemc->delete( wfMemcKey( 'messages', $code ) ); @@ -890,8 +911,7 @@ class MessageCache { } $lang = array_pop( $pieces ); - $validCodes = Language::getLanguageNames(); - if( !array_key_exists( $lang, $validCodes ) ) { + if( !Language::fetchLanguageName( $lang, null, 'mw' ) ) { return array( $key, $wgLanguageCode ); } |