Merge "Replace deprecated wfMsg* calls with Message class calls."
authorIAlex <ialex.wiki@gmail.com>
Fri, 31 Aug 2012 13:15:45 +0000 (13:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 31 Aug 2012 13:15:45 +0000 (13:15 +0000)
includes/Title.php
includes/User.php
includes/UserMailer.php
includes/WikiError.php
includes/WikiPage.php

index 94ae062..eccae70 100644 (file)
@@ -347,7 +347,7 @@ class Title {
         * @return Title the new object
         */
        public static function newMainPage() {
-               $title = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+               $title = Title::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() );
                // Don't give fatal errors if the message is broken
                if ( !$title ) {
                        $title = Title::newFromText( 'Main Page' );
@@ -1594,7 +1594,7 @@ class Title {
         *   queries by skipping checks for cascading protections and user blocks.
         * @param $ignoreErrors Array of Strings Set this to a list of message keys
         *   whose corresponding errors may be ignored.
-        * @return Array of arguments to wfMsg to explain permissions problems.
+        * @return Array of arguments to wfMessage to explain permissions problems.
         */
        public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true, $ignoreErrors = array() ) {
                $errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
@@ -1751,7 +1751,7 @@ class Title {
                # Check $wgNamespaceProtection for restricted namespaces
                if ( $this->isNamespaceProtected( $user ) ) {
                        $ns = $this->mNamespace == NS_MAIN ?
-                               wfMsg( 'nstab-main' ) : $this->getNsText();
+                               wfMessage( 'nstab-main' )->text() : $this->getNsText();
                        $errors[] = $this->mNamespace == NS_MEDIAWIKI ?
                                array( 'protectedinterface' ) : array( 'namespaceprotected',  $ns );
                }
@@ -1950,7 +1950,7 @@ class Title {
                        $id = $user->blockedBy();
                        $reason = $user->blockedFor();
                        if ( $reason == '' ) {
-                               $reason = wfMsg( 'blockednoreason' );
+                               $reason = wfMessage( 'blockednoreason' )->text();
                        }
                        $ip = $user->getRequest()->getIP();
 
@@ -2108,7 +2108,7 @@ class Title {
         * @param $user User to check
         * @param $doExpensiveQueries Bool Set this to false to avoid doing unnecessary queries.
         * @param $short Bool Set this to true to stop after the first permission error.
-        * @return Array of arrays of the arguments to wfMsg to explain permissions problems.
+        * @return Array of arrays of the arguments to wfMessage to explain permissions problems.
         */
        protected function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true, $short = false ) {
                wfProfileIn( __METHOD__ );
@@ -3546,9 +3546,13 @@ class Title {
                        );
                        # Update the protection log
                        $log = new LogPage( 'protect' );
-                       $comment = wfMsgForContent( 'prot_1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
+                       $comment = wfMessage(
+                               'prot_1movedto2',
+                               $this->getPrefixedText(),
+                               $nt->getPrefixedText()
+                       )->inContentLanguage()->text();
                        if ( $reason ) {
-                               $comment .= wfMsgForContent( 'colon-separator' ) . $reason;
+                               $comment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
                        }
                        // @todo FIXME: $params?
                        $log->addEntry( 'move_prot', $nt, $comment, array( $this->getPrefixedText() ) );
@@ -3606,7 +3610,7 @@ class Title {
                $formatter->setContext( RequestContext::newExtraneousContext( $this ) );
                $comment = $formatter->getPlainActionText();
                if ( $reason ) {
-                       $comment .= wfMsgForContent( 'colon-separator' ) . $reason;
+                       $comment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
                }
                # Truncate for whole multibyte characters.
                $comment = $wgContLang->truncate( $comment, 255 );
index f43844e..13748de 100644 (file)
@@ -624,7 +624,7 @@ class User {
                // Certain names may be reserved for batch processes.
                foreach ( $reservedUsernames as $reserved ) {
                        if ( substr( $reserved, 0, 4 ) == 'msg:' ) {
-                               $reserved = wfMsgForContent( substr( $reserved, 4 ) );
+                               $reserved = wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
                        }
                        if ( $reserved == $name ) {
                                return false;
@@ -1305,13 +1305,13 @@ class User {
                        # Local list
                        if ( self::isLocallyBlockedProxy( $ip ) ) {
                                $block = new Block;
-                               $block->setBlocker( wfMsg( 'proxyblocker' ) );
-                               $block->mReason = wfMsg( 'proxyblockreason' );
+                               $block->setBlocker( wfMessage( 'proxyblocker' )->text() );
+                               $block->mReason = wfMessage( 'proxyblockreason' )->text();
                                $block->setTarget( $ip );
                        } elseif ( $this->isAnon() && $this->isDnsBlacklisted( $ip ) ) {
                                $block = new Block;
-                               $block->setBlocker( wfMsg( 'sorbs' ) );
-                               $block->mReason = wfMsg( 'sorbsreason' );
+                               $block->setBlocker( wfMessage( 'sorbs' )->text() );
+                               $block->mReason = wfMessage( 'sorbsreason' )->text();
                                $block->setTarget( $ip );
                        }
                }
@@ -2016,7 +2016,7 @@ class User {
 
                if( $str !== null ) {
                        if( !$wgAuth->allowPasswordChange() ) {
-                               throw new PasswordError( wfMsg( 'password-change-forbidden' ) );
+                               throw new PasswordError( wfMessage( 'password-change-forbidden' )->text() );
                        }
 
                        if( !$this->isValidPassword( $str ) ) {
@@ -2029,12 +2029,12 @@ class User {
                                        $message = $valid;
                                        $params = array( $wgMinimalPasswordLength );
                                }
-                               throw new PasswordError( wfMsgExt( $message, array( 'parsemag' ), $params ) );
+                               throw new PasswordError( wfMessage( $message, $params )->text() );
                        }
                }
 
                if( !$wgAuth->setPassword( $this, $str ) ) {
-                       throw new PasswordError( wfMsg( 'externaldberror' ) );
+                       throw new PasswordError( wfMessage( 'externaldberror' )->text() );
                }
 
                $this->setInternalPassword( $str );
@@ -3353,15 +3353,15 @@ class User {
                        $message = 'confirmemail_body_' . $type;
                }
 
-               return $this->sendMail( wfMsg( 'confirmemail_subject' ),
-                       wfMsg( $message,
+               return $this->sendMail( wfMessage( 'confirmemail_subject' )->text(),
+                       wfMessage( $message,
                                $this->getRequest()->getIP(),
                                $this->getName(),
                                $url,
                                $wgLang->timeanddate( $expiration, false ),
                                $invalidateURL,
                                $wgLang->date( $expiration, false ),
-                               $wgLang->time( $expiration, false ) ) );
+                               $wgLang->time( $expiration, false ) )->text() );
        }
 
        /**
@@ -4013,10 +4013,10 @@ class User {
                        $action = 'create2';
                        if ( $byEmail ) {
                                if ( $reason === '' ) {
-                                       $reason = wfMsgForContent( 'newuserlog-byemail' );
+                                       $reason = wfMessage( 'newuserlog-byemail' )->inContentLanguage()->text();
                                } else {
                                        $reason = $wgContLang->commaList( array(
-                                               $reason, wfMsgForContent( 'newuserlog-byemail' ) ) );
+                                               $reason, wfMessage( 'newuserlog-byemail' )->inContentLanguage()->text() ) );
                                }
                        }
                }
@@ -4185,8 +4185,8 @@ class User {
                /*
                if ( $wgMinimalPasswordLength > 1 ) {
                        $ret['pattern'] = '.{' . intval( $wgMinimalPasswordLength ) . ',}';
-                       $ret['title'] = wfMsgExt( 'passwordtooshort', 'parsemag',
-                               $wgMinimalPasswordLength );
+                       $ret['title'] = wfMessage( 'passwordtooshort' )
+                               ->numParams( $wgMinimalPasswordLength )->text();
                }
                */
 
index 36da6fb..01e7132 100644 (file)
@@ -623,32 +623,36 @@ class EmailNotification {
 
                if ( $this->oldid ) {
                        // Always show a link to the diff which triggered the mail. See bug 32210.
-                       $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff',
-                               $this->title->getCanonicalUrl( 'diff=next&oldid=' . $this->oldid ) );
+                       $keys['$NEWPAGE'] = wfMessage( 'enotif_lastdiff',
+                               $this->title->getCanonicalUrl( 'diff=next&oldid=' . $this->oldid ) )
+                               ->inContentLanguage()->text();
                        if ( !$wgEnotifImpersonal ) {
                                // For personal mail, also show a link to the diff of all changes
                                // since last visited.
-                               $keys['$NEWPAGE'] .= " \n" . wfMsgForContent( 'enotif_lastvisited',
-                                       $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ) );
+                               $keys['$NEWPAGE'] .= " \n" . wfMessage( 'enotif_lastvisited',
+                                       $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ) )
+                                       ->inContentLanguage()->text();
                        }
                        $keys['$OLDID']   = $this->oldid;
-                       $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' );
+                       $keys['$CHANGEDORCREATED'] = wfMessage( 'changed' )->inContentLanguage()->text();
                } else {
-                       $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_newpagetext' );
+                       $keys['$NEWPAGE'] = wfMessage( 'enotif_newpagetext' )->inContentLanguage()->text();
                        # clear $OLDID placeholder in the message template
                        $keys['$OLDID']   = '';
-                       $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
+                       $keys['$CHANGEDORCREATED'] = wfMessage( 'created' )->inContentLanguage()->text();
                }
 
                $keys['$PAGETITLE'] = $this->title->getPrefixedText();
                $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl();
-               $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMsgForContent( 'minoredit' ) : '';
+               $keys['$PAGEMINOREDIT'] = $this->minorEdit ?
+                       wfMessage( 'minoredit' )->inContentLanguage()->text() : '';
                $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' );
 
                if ( $this->editor->isAnon() ) {
                        # real anon (user:xxx.xxx.xxx.xxx)
-                       $keys['$PAGEEDITOR'] = wfMsgForContent( 'enotif_anon_editor', $this->editor->getName() );
-                       $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
+                       $keys['$PAGEEDITOR'] = wfMessage( 'enotif_anon_editor', $this->editor->getName() )
+                               ->inContentLanguage()->text();
+                       $keys['$PAGEEDITOR_EMAIL'] = wfMessage( 'noemailtitle' )->inContentLanguage()->text();
                } else {
                        $keys['$PAGEEDITOR'] = $wgEnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
                        $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $this->editor->getName() );
@@ -662,12 +666,12 @@ class EmailNotification {
 
                # Now build message's subject and body
 
-               $subject = wfMsgExt( 'enotif_subject', 'content' );
+               $subject = wfMessage( 'enotif_subject' )->inContentLanguage()->plain();
                $subject = strtr( $subject, $keys );
                $subject = MessageCache::singleton()->transform( $subject, false, null, $this->title );
                $this->subject = strtr( $subject, $postTransformKeys );
 
-               $body = wfMsgExt( 'enotif_body', 'content' );
+               $body = wfMessage( 'enotif_body' )->inContentLanguage()->plain();
                $body = strtr( $body, $keys );
                $body = MessageCache::singleton()->transform( $body, false, null, $this->title );
                $this->body = wordwrap( strtr( $body, $postTransformKeys ), 72 );
@@ -769,7 +773,7 @@ class EmailNotification {
                                array( '$WATCHINGUSERNAME',
                                        '$PAGEEDITDATE',
                                        '$PAGEEDITTIME' ),
-                               array( wfMsgForContent( 'enotif_impersonal_salutation' ),
+                               array( wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(),
                                        $wgContLang->date( $this->timestamp, false, false ),
                                        $wgContLang->time( $this->timestamp, false, false ) ),
                                $this->body );
index 7c167f6..4b0e68c 100644 (file)
@@ -134,12 +134,12 @@ class WikiXmlError extends WikiError {
        /** @return string */
        function getMessage() {
                // '$1 at line $2, col $3 (byte $4): $5',
-               return wfMsgHtml( 'xml-error-string',
+               return wfMessage( 'xml-error-string',
                        $this->mMessage,
                        $this->mLine,
                        $this->mColumn,
                        $this->mByte . $this->mContext,
-                       xml_error_string( $this->mXmlError ) );
+                       xml_error_string( $this->mXmlError ) )->escaped();
        }
 
        function _extractContext( $context, $offset ) {
index a4e1d8d..1021767 100644 (file)
@@ -92,6 +92,7 @@ class WikiPage extends Page implements IDBAccessObject {
         * Create a WikiPage object of the appropriate class for the given title.
         *
         * @param $title Title
+        * @throws MWException
         * @return WikiPage object of the appropriate type
         */
        public static function factory( Title $title ) {
@@ -711,7 +712,7 @@ class WikiPage extends Page implements IDBAccessObject {
         * Determine whether a page would be suitable for being counted as an
         * article in the site_stats table based on the title & its content
         *
-        * @param $editInfo Object or false: object returned by prepareTextForEdit(),
+        * @param $editInfo Object|bool (false): object returned by prepareTextForEdit(),
         *        if false, the current database state will be used
         * @return Boolean
         */
@@ -1326,7 +1327,8 @@ class WikiPage extends Page implements IDBAccessObject {
 
                        if ( $section == 'new' ) {
                                # Inserting a new section
-                               $subject = $sectionTitle ? wfMsgForContent( 'newsectionheaderdefaultlevel', $sectionTitle ) . "\n\n" : '';
+                               $subject = $sectionTitle ? wfMessage( 'newsectionheaderdefaultlevel' )
+                                       ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
                                if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
                                        $text = strlen( trim( $oldtext ) ) > 0
                                                ? "{$oldtext}\n\n{$subject}{$text}"
@@ -1389,9 +1391,10 @@ class WikiPage extends Page implements IDBAccessObject {
         * edit-already-exists error will be returned. These two conditions are also possible with
         * auto-detection due to MediaWiki's performance-optimised locking strategy.
         *
-        * @param $baseRevId int the revision ID this edit was based off, if any
+        * @param bool|int $baseRevId int the revision ID this edit was based off, if any
         * @param $user User the user doing the edit
         *
+        * @throws MWException
         * @return Status object. Possible errors:
         *     edit-hook-aborted:       The ArticleSave hook aborted the edit but didn't set the fatal flag of $status
         *     edit-gone-missing:       In update mode, but the article didn't exist
@@ -1930,12 +1933,15 @@ class WikiPage extends Page implements IDBAccessObject {
                        if ( $restrictions != '' ) {
                                $protectDescription .= $wgContLang->getDirMark() . "[$action=$restrictions] (";
                                if ( $encodedExpiry[$action] != 'infinity' ) {
-                                       $protectDescription .= wfMsgForContent( 'protect-expiring',
+                                       $protectDescription .= wfMessage(
+                                               'protect-expiring',
                                                $wgContLang->timeanddate( $expiry[$action], false, false ) ,
                                                $wgContLang->date( $expiry[$action], false, false ) ,
-                                               $wgContLang->time( $expiry[$action], false, false ) );
+                                               $wgContLang->time( $expiry[$action], false, false )
+                                       )->inContentLanguage()->text();
                                } else {
-                                       $protectDescription .= wfMsgForContent( 'protect-expiry-indefinite' );
+                                       $protectDescription .= wfMessage( 'protect-expiry-indefinite' )
+                                               ->inContentLanguage()->text();
                                }
 
                                $protectDescription .= ') ';
@@ -1976,7 +1982,12 @@ class WikiPage extends Page implements IDBAccessObject {
                        }
 
                        # Prepare a null revision to be added to the history
-                       $editComment = $wgContLang->ucfirst( wfMsgForContent( $revCommentMsg, $this->mTitle->getPrefixedText() ) );
+                       $editComment = $wgContLang->ucfirst(
+                               wfMessage(
+                                       $revCommentMsg,
+                                       $this->mTitle->getPrefixedText()
+                               )->inContentLanguage()->text()
+                       );
                        if ( $reason ) {
                                $editComment .= ": $reason";
                        }
@@ -1984,7 +1995,9 @@ class WikiPage extends Page implements IDBAccessObject {
                                $editComment .= " ($protectDescription)";
                        }
                        if ( $cascade ) {
-                               $editComment .= ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']';
+                               // FIXME: Should use 'brackets' message.
+                               $editComment .= ' [' . wfMessage( 'protect-summary-cascade' )
+                                       ->inContentLanguage()->text() . ']';
                        }
 
                        # Insert a null revision
@@ -2051,6 +2064,7 @@ class WikiPage extends Page implements IDBAccessObject {
         * Take an array of page restrictions and flatten it to a string
         * suitable for insertion into the page_restrictions field.
         * @param $limit Array
+        * @throws MWException
         * @return String
         */
        protected static function flattenRestrictions( $limit ) {
@@ -2392,9 +2406,9 @@ class WikiPage extends Page implements IDBAccessObject {
                $target = Revision::newFromId( $s->rev_id );
                if ( empty( $summary ) ) {
                        if ( $from == '' ) { // no public user name
-                               $summary = wfMsgForContent( 'revertpage-nouser' );
+                               $summary = wfMessage( 'revertpage-nouser' )->inContentLanguage()->text();
                        } else {
-                               $summary = wfMsgForContent( 'revertpage' );
+                               $summary = wfMessage( 'revertpage' )->inContentLanguage()->text();
                        }
                }
 
@@ -2585,10 +2599,11 @@ class WikiPage extends Page implements IDBAccessObject {
                        $truncatedtext = $wgContLang->truncate(
                                str_replace( "\n", ' ', $newtext ),
                                max( 0, 255
-                                       - strlen( wfMsgForContent( 'autoredircomment' ) )
+                                       - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() )
                                        - strlen( $rt->getFullText() )
                                ) );
-                       return wfMsgForContent( 'autoredircomment', $rt->getFullText(), $truncatedtext );
+                       return wfMessage( 'autoredircomment', $rt->getFullText() )
+                               ->rawParams( $truncatedtext )->inContentLanguage()->text();
                }
 
                # New page autosummaries
@@ -2597,22 +2612,24 @@ class WikiPage extends Page implements IDBAccessObject {
 
                        $truncatedtext = $wgContLang->truncate(
                                str_replace( "\n", ' ', $newtext ),
-                               max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) );
+                               max( 0, 200 - strlen( wfMessage( 'autosumm-new' )->inContentLanguage()->text() ) ) );
 
-                       return wfMsgForContent( 'autosumm-new', $truncatedtext );
+                       return wfMessage( 'autosumm-new' )->rawParams( $truncatedtext )
+                               ->inContentLanguage()->text();
                }
 
                # Blanking autosummaries
                if ( $oldtext != '' && $newtext == '' ) {
-                       return wfMsgForContent( 'autosumm-blank' );
+                       return wfMessage( 'autosumm-blank' )->inContentLanguage()->text();
                } elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) {
                        # Removing more than 90% of the article
 
                        $truncatedtext = $wgContLang->truncate(
                                $newtext,
-                               max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ) );
+                               max( 0, 200 - strlen( wfMessage( 'autosumm-replace' )->inContentLanguage()->text() ) ) );
 
-                       return wfMsgForContent( 'autosumm-replace', $truncatedtext );
+                       return wfMessage( 'autosumm-replace' )->rawParams( $truncatedtext )
+                               ->inContentLanguage()->text();
                }
 
                # If we reach this point, there's no applicable autosummary for our case, so our
@@ -2687,12 +2704,16 @@ class WikiPage extends Page implements IDBAccessObject {
                if ( $blank ) {
                        // The current revision is blank and the one before is also
                        // blank. It's just not our lucky day
-                       $reason = wfMsgForContent( 'exbeforeblank', '$1' );
+                       $reason = wfMessage( 'exbeforeblank', '$1' )->inContentLanguage()->text();
                } else {
                        if ( $onlyAuthor ) {
-                               $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor );
+                               $reason = wfMessage(
+                                       'excontentauthor',
+                                       '$1',
+                                       $onlyAuthor
+                               )->inContentLanguage()->text();
                        } else {
-                               $reason = wfMsgForContent( 'excontent', '$1' );
+                               $reason = wfMessage( 'excontent', '$1' )->inContentLanguage()->text();
                        }
                }
 
@@ -2946,6 +2967,7 @@ class WikiPage extends Page implements IDBAccessObject {
 
        /**
         * @deprecated since 1.18
+        * @param $oldid int
         * @return bool
         */
        public function useParserCache( $oldid ) {