aboutsummaryrefslogtreecommitdiffstats
path: root/includes/MessageCache.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@users.mediawiki.org>2005-03-13 11:50:54 +0000
committerBrion Vibber <brion@users.mediawiki.org>2005-03-13 11:50:54 +0000
commit63c344e80c3d0f1cd570b873bc09b9a6b936a445 (patch)
treef03b68fb69032eec795059721db12fd79b4556b7 /includes/MessageCache.php
parent15ef75e3682f1167e51f3f207a72f71bf3f9fc10 (diff)
downloadmediawikicore-63c344e80c3d0f1cd570b873bc09b9a6b936a445.tar.gz
mediawikicore-63c344e80c3d0f1cd570b873bc09b9a6b936a445.zip
For custom messages, fall back to the default language's db messages
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/7676
Diffstat (limited to 'includes/MessageCache.php')
-rwxr-xr-xincludes/MessageCache.php80
1 files changed, 47 insertions, 33 deletions
diff --git a/includes/MessageCache.php b/includes/MessageCache.php
index b260f4cb34e5..f97e73ccd736 100755
--- a/includes/MessageCache.php
+++ b/includes/MessageCache.php
@@ -242,39 +242,7 @@ class MessageCache
if(!$isfullkey && ($langcode != $wgContLanguageCode) ) {
$title .= '/' . $langcode;
}
-
- # Try the cache
- if( $this->mUseCache && is_array( $this->mCache ) && array_key_exists( $title, $this->mCache ) ) {
- $message = $this->mCache[$title];
- }
-
- if ( !$message && $this->mUseCache ) {
- $message = $this->mMemc->get( $this->mMemcKey . ':' . $title );
- if( $message ) {
- $this->mCache[$title] = $message;
- }
- }
-
- # If it wasn't in the cache, load each message from the DB individually
- if ( !$message ) {
- $dbr =& wfGetDB( DB_SLAVE );
- $result = $dbr->selectRow( array( 'page', 'text' ),
- array( 'old_flags', 'old_text' ),
- 'page_namespace=' . NS_MEDIAWIKI .
- ' AND page_title=' . $dbr->addQuotes( $title ) .
- ' AND page_latest=old_id',
- 'MessageCache::get' );
- if ( $result ) {
- $message = Revision::getRevisionText( $result );
- if ($this->mUseCache) {
- $this->mCache[$title]=$message;
- /* individual messages may be often
- recached until proper purge code exists
- */
- $this->mMemc->set( $this->mMemcKey . ':' . $title, $message, 300 );
- }
- }
- }
+ $message = $this->getFromCache( $title );
}
# Try the extension array
if( !$message ) {
@@ -295,6 +263,13 @@ class MessageCache
wfRestoreWarnings();
}
+ # Is this a custom message? Try the default language in the db...
+ if( !$message &&
+ !$this->mDisable && $useDB &&
+ !$isfullkey && ($langcode != $wgContLanguageCode) ) {
+ $message = $this->getFromCache( $lang->ucfirst( $key ) );
+ }
+
# Final fallback
if( !$message ) {
$message = "&lt;$key&gt;";
@@ -304,6 +279,45 @@ class MessageCache
$message = $this->transform( $message );
return $message;
}
+
+ function getFromCache( $title ) {
+ $message = false;
+
+ # Try the cache
+ if( $this->mUseCache && is_array( $this->mCache ) && array_key_exists( $title, $this->mCache ) ) {
+ $message = $this->mCache[$title];
+ }
+
+ if ( !$message && $this->mUseCache ) {
+ $message = $this->mMemc->get( $this->mMemcKey . ':' . $title );
+ if( $message ) {
+ $this->mCache[$title] = $message;
+ }
+ }
+
+ # If it wasn't in the cache, load each message from the DB individually
+ if ( !$message ) {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $result = $dbr->selectRow( array( 'page', 'text' ),
+ array( 'old_flags', 'old_text' ),
+ 'page_namespace=' . NS_MEDIAWIKI .
+ ' AND page_title=' . $dbr->addQuotes( $title ) .
+ ' AND page_latest=old_id',
+ 'MessageCache::get' );
+ if ( $result ) {
+ $message = Revision::getRevisionText( $result );
+ if ($this->mUseCache) {
+ $this->mCache[$title]=$message;
+ /* individual messages may be often
+ recached until proper purge code exists
+ */
+ $this->mMemc->set( $this->mMemcKey . ':' . $title, $message, 300 );
+ }
+ }
+ }
+
+ return $message;
+ }
function transform( $message ) {
if( !$this->mDisableTransform ) {