Deprecated wfMsgWeirdKey(), use wfMessage() instead. Moved getDefaultMessageText...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 5 Feb 2011 15:11:52 +0000 (15:11 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 5 Feb 2011 15:11:52 +0000 (15:11 +0000)
includes/Article.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/Title.php
maintenance/addwiki.php

index 59e4c85..666b2dd 100644 (file)
@@ -257,7 +257,7 @@ class Article {
                        # If this is a MediaWiki:x message, then load the messages
                        # and return the message value for x.
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                               $text = $this->getDefaultMessageText();
+                               $text = $this->mTitle->getDefaultMessageText();
                                if ( $text === false ) {
                                        $text = '';
                                }
@@ -275,28 +275,6 @@ class Article {
                }
        }
 
-       /**
-        * Get the default message text or false if the message doesn't exist
-        *
-        * @return String or false
-        */
-       public function getDefaultMessageText() {
-               global $wgContLang;
-
-               if ( $this->mTitle->getNamespace() != NS_MEDIAWIKI ) { // Just in case
-                       return false;
-               }
-
-               list( $name, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
-               $message = wfMessage( $name )->inLanguage( $lang )->useDatabase( false );
-
-               if ( $message->exists() ) {
-                       return $message->plain();
-               } else {
-                       return false;
-               }
-       }
-
        /**
         * Get the text of the current revision. No side-effects...
         *
@@ -1411,7 +1389,7 @@ class Article {
                                wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
                } elseif ( $this->mTitle->getNamespace() === NS_MEDIAWIKI ) {
                        // Use the default message text
-                       $text = $this->getDefaultMessageText();
+                       $text = $this->mTitle->getDefaultMessageText();
                } else {
                        $createErrors = $this->mTitle->getUserPermissionsErrors( 'create', $wgUser );
                        $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
@@ -4162,7 +4140,7 @@ class Article {
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                                // This doesn't quite make sense; the user is asking for
                                // information about the _page_, not the message... -- RC
-                               $wgOut->addHTML( htmlspecialchars( wfMsgWeirdKey( $this->mTitle->getText() ) ) );
+                               $wgOut->addHTML( htmlspecialchars( $this->mTitle->getDefaultMessageText() ) );
                        } else {
                                $msg = $wgUser->isLoggedIn()
                                        ? 'noarticletext'
index 8ed9167..57d2590 100644 (file)
@@ -141,7 +141,7 @@ class EditPage {
                if ( !$this->mTitle->exists() ) {
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                                # If this is a system message, get the default text.
-                               $text = $this->mArticle->getDefaultMessageText();
+                               $text = $this->mTitle->getDefaultMessageText();
                                if( $text === false ) {
                                        $text = $this->getPreloadedText( $preload );
                                }
index 334ad86..9af9b92 100644 (file)
@@ -607,7 +607,9 @@ function wfMsgReal( $key, $args, $useDB = true, $forContent = false, $transform
 
 /**
  * This function provides the message source for messages to be edited which are *not* stored in the database.
- * @param $key String:
+ *
+ * @deprecated in 1.18; use wfMessage()
+ * @param $key String
  */
 function wfMsgWeirdKey( $key ) {
        $source = wfMsgGetKey( $key, false, true, false );
index 38cc327..ca5aa66 100644 (file)
@@ -3760,12 +3760,8 @@ class Title {
                                // selflink, possibly with fragment
                                return $this->mDbkeyform == '';
                        case NS_MEDIAWIKI:
-                               // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes
-                               // the full l10n of that language to be loaded. That takes much memory and
-                               // isn't needed. So we strip the language part away.
-                               list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 );
                                // known system message
-                               return (bool)wfMsgWeirdKey( $basename );
+                               return $this->getDefaultMessageText() !== false;
                        default:
                                return false;
                }
@@ -3796,16 +3792,34 @@ class Title {
                if ( $this->mNamespace == NS_MEDIAWIKI ) {
                        // If the page doesn't exist but is a known system message, default
                        // message content will be displayed, same for language subpages
-                       // Also, if the page is form Mediawiki:message/lang, calling wfMsgWeirdKey
-                       // causes the full l10n of that language to be loaded. That takes much
-                       // memory and isn't needed. So we strip the language part away.
-                       list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 );
-                       return (bool)wfMsgWeirdKey( $basename );
+                       return $this->getDefaultMessageText() !== false;
                }
 
                return false;
        }
 
+       /**
+        * Get the default message text or false if the message doesn't exist
+        *
+        * @return String or false
+        */
+       public function getDefaultMessageText() {
+               global $wgContLang;
+
+               if ( $this->getNamespace() != NS_MEDIAWIKI ) { // Just in case
+                       return false;
+               }
+
+               list( $name, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->getText() ) );
+               $message = wfMessage( $name )->inLanguage( $lang )->useDatabase( false );
+
+               if ( $message->exists() ) {
+                       return $message->plain();
+               } else {
+                       return false;
+               }
+       }
+
        /**
         * Is this in a namespace that allows actual pages?
         *
index cccef15..73e2ebe 100644 (file)
@@ -129,7 +129,7 @@ class AddWiki extends Maintenance {
                        }
                }
 
-               $title = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
+               $title = Title::newFromText( wfMessage( 'mainpage' )->inLanguage( $lang )->useDatabase( false )->plain() );
                $this->output( "Writing main page to " . $title->getPrefixedDBkey() . "\n" );
                $article = new Article( $title );
                $ucsite = ucfirst( $site );