r81563 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81562‎ | r81563 | r81564 >
Date:15:11, 5 February 2011
Author:ialex
Status:ok
Tags:
Comment:
Deprecated wfMsgWeirdKey(), use wfMessage() instead. Moved getDefaultMessageText() from Article to Title so that it can be used there instead of duplicating code. No usage in extensions.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/maintenance/addwiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/addwiki.php
@@ -129,7 +129,7 @@
130130 }
131131 }
132132
133 - $title = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
 133+ $title = Title::newFromText( wfMessage( 'mainpage' )->inLanguage( $lang )->useDatabase( false )->plain() );
134134 $this->output( "Writing main page to " . $title->getPrefixedDBkey() . "\n" );
135135 $article = new Article( $title );
136136 $ucsite = ucfirst( $site );
Index: trunk/phase3/includes/Article.php
@@ -257,7 +257,7 @@
258258 # If this is a MediaWiki:x message, then load the messages
259259 # and return the message value for x.
260260 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
261 - $text = $this->getDefaultMessageText();
 261+ $text = $this->mTitle->getDefaultMessageText();
262262 if ( $text === false ) {
263263 $text = '';
264264 }
@@ -276,28 +276,6 @@
277277 }
278278
279279 /**
280 - * Get the default message text or false if the message doesn't exist
281 - *
282 - * @return String or false
283 - */
284 - public function getDefaultMessageText() {
285 - global $wgContLang;
286 -
287 - if ( $this->mTitle->getNamespace() != NS_MEDIAWIKI ) { // Just in case
288 - return false;
289 - }
290 -
291 - list( $name, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
292 - $message = wfMessage( $name )->inLanguage( $lang )->useDatabase( false );
293 -
294 - if ( $message->exists() ) {
295 - return $message->plain();
296 - } else {
297 - return false;
298 - }
299 - }
300 -
301 - /**
302280 * Get the text of the current revision. No side-effects...
303281 *
304282 * @return Return the text of the current revision
@@ -1411,7 +1389,7 @@
14121390 wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
14131391 } elseif ( $this->mTitle->getNamespace() === NS_MEDIAWIKI ) {
14141392 // Use the default message text
1415 - $text = $this->getDefaultMessageText();
 1393+ $text = $this->mTitle->getDefaultMessageText();
14161394 } else {
14171395 $createErrors = $this->mTitle->getUserPermissionsErrors( 'create', $wgUser );
14181396 $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
@@ -4162,7 +4140,7 @@
41634141 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
41644142 // This doesn't quite make sense; the user is asking for
41654143 // information about the _page_, not the message... -- RC
4166 - $wgOut->addHTML( htmlspecialchars( wfMsgWeirdKey( $this->mTitle->getText() ) ) );
 4144+ $wgOut->addHTML( htmlspecialchars( $this->mTitle->getDefaultMessageText() ) );
41674145 } else {
41684146 $msg = $wgUser->isLoggedIn()
41694147 ? 'noarticletext'
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -607,7 +607,9 @@
608608
609609 /**
610610 * This function provides the message source for messages to be edited which are *not* stored in the database.
611 - * @param $key String:
 611+ *
 612+ * @deprecated in 1.18; use wfMessage()
 613+ * @param $key String
612614 */
613615 function wfMsgWeirdKey( $key ) {
614616 $source = wfMsgGetKey( $key, false, true, false );
Index: trunk/phase3/includes/EditPage.php
@@ -141,7 +141,7 @@
142142 if ( !$this->mTitle->exists() ) {
143143 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
144144 # If this is a system message, get the default text.
145 - $text = $this->mArticle->getDefaultMessageText();
 145+ $text = $this->mTitle->getDefaultMessageText();
146146 if( $text === false ) {
147147 $text = $this->getPreloadedText( $preload );
148148 }
Index: trunk/phase3/includes/Title.php
@@ -3760,12 +3760,8 @@
37613761 // selflink, possibly with fragment
37623762 return $this->mDbkeyform == '';
37633763 case NS_MEDIAWIKI:
3764 - // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes
3765 - // the full l10n of that language to be loaded. That takes much memory and
3766 - // isn't needed. So we strip the language part away.
3767 - list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 );
37683764 // known system message
3769 - return (bool)wfMsgWeirdKey( $basename );
 3765+ return $this->getDefaultMessageText() !== false;
37703766 default:
37713767 return false;
37723768 }
@@ -3796,17 +3792,35 @@
37973793 if ( $this->mNamespace == NS_MEDIAWIKI ) {
37983794 // If the page doesn't exist but is a known system message, default
37993795 // message content will be displayed, same for language subpages
3800 - // Also, if the page is form Mediawiki:message/lang, calling wfMsgWeirdKey
3801 - // causes the full l10n of that language to be loaded. That takes much
3802 - // memory and isn't needed. So we strip the language part away.
3803 - list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 );
3804 - return (bool)wfMsgWeirdKey( $basename );
 3796+ return $this->getDefaultMessageText() !== false;
38053797 }
38063798
38073799 return false;
38083800 }
38093801
38103802 /**
 3803+ * Get the default message text or false if the message doesn't exist
 3804+ *
 3805+ * @return String or false
 3806+ */
 3807+ public function getDefaultMessageText() {
 3808+ global $wgContLang;
 3809+
 3810+ if ( $this->getNamespace() != NS_MEDIAWIKI ) { // Just in case
 3811+ return false;
 3812+ }
 3813+
 3814+ list( $name, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->getText() ) );
 3815+ $message = wfMessage( $name )->inLanguage( $lang )->useDatabase( false );
 3816+
 3817+ if ( $message->exists() ) {
 3818+ return $message->plain();
 3819+ } else {
 3820+ return false;
 3821+ }
 3822+ }
 3823+
 3824+ /**
38113825 * Is this in a namespace that allows actual pages?
38123826 *
38133827 * @return Bool

Status & tagging log