Merge "[FileRepo] Various code cleanups."
authorHashar <hashar@free.fr>
Fri, 6 Apr 2012 06:45:16 +0000 (06:45 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 6 Apr 2012 06:45:16 +0000 (06:45 +0000)
RELEASE-NOTES-1.20
includes/EditPage.php
includes/Pager.php
includes/SkinTemplate.php
includes/specials/SpecialDeletedContributions.php
includes/specials/SpecialMovepage.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc
tests/phpunit/includes/api/ApiBlockTest.php

index 3f6a79f..9c05349 100644 (file)
@@ -34,6 +34,7 @@ production.
 * (bug 34355) add a variable and parser function for the namespace number.
 * (bug 35649) Special:Version now shows hashes of extensions checked out from git.
 * (bug 35728) Git revisions are now linked on Special:Version.
+* "Show Changes" on default messages shows now diff against default message text
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index 0b879c1..69187e4 100644 (file)
@@ -2335,7 +2335,16 @@ HTML
        function showDiff() {
                global $wgUser, $wgContLang, $wgParser, $wgOut;
 
-               $oldtext = $this->mArticle->getRawText();
+               $oldtitlemsg = 'currentrev';
+               # if message does not exist, show diff against the preloaded default
+               if( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists() ) {
+                       $oldtext = $this->mTitle->getDefaultMessageText();
+                       if( $oldtext !== false ) {
+                               $oldtitlemsg = 'defaultmessagetext';
+                       }
+               } else {
+                       $oldtext = $this->mArticle->getRawText();
+               }
                $newtext = $this->mArticle->replaceSection(
                        $this->section, $this->textbox1, $this->summary, $this->edittime );
 
@@ -2345,7 +2354,7 @@ HTML
                $newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts );
 
                if ( $oldtext !== false  || $newtext != '' ) {
-                       $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) );
+                       $oldtitle = wfMsgExt( $oldtitlemsg, array( 'parseinline' ) );
                        $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) );
 
                        $de = new DifferenceEngine( $this->mArticle->getContext() );
index e2c7751..472cb48 100644 (file)
@@ -366,9 +366,10 @@ abstract class IndexPager extends ContextSource implements Pager {
         * @param $text String: text displayed on the link
         * @param $query Array: associative array of paramter to be in the query string
         * @param $type String: value of the "rel" attribute
+        *
         * @return String: HTML fragment
         */
-       function makeLink($text, $query = null, $type=null) {
+       function makeLink( $text, array $query = null, $type = null ) {
                if ( $query === null ) {
                        return $text;
                }
@@ -382,6 +383,7 @@ abstract class IndexPager extends ContextSource implements Pager {
                if( $type ) {
                        $attrs['class'] = "mw-{$type}link";
                }
+
                return Linker::linkKnown(
                        $this->getTitle(),
                        $text,
@@ -526,6 +528,7 @@ abstract class IndexPager extends ContextSource implements Pager {
        function getPagingLinks( $linkTexts, $disabledTexts = array() ) {
                $queries = $this->getPagingQueries();
                $links = array();
+
                foreach ( $queries as $type => $query ) {
                        if ( $query !== false ) {
                                $links[$type] = $this->makeLink(
@@ -539,6 +542,7 @@ abstract class IndexPager extends ContextSource implements Pager {
                                $links[$type] = $linkTexts[$type];
                        }
                }
+
                return $links;
        }
 
@@ -651,7 +655,9 @@ abstract class AlphabeticPager extends IndexPager {
         * @return String HTML
         */
        function getNavigationBar() {
-               if ( !$this->isNavigationBarShown() ) return '';
+               if ( !$this->isNavigationBarShown() ) {
+                       return '';
+               }
 
                if( isset( $this->mNavigationBar ) ) {
                        return $this->mNavigationBar;
@@ -682,10 +688,10 @@ abstract class AlphabeticPager extends IndexPager {
                $this->mNavigationBar = wfMessage( 'parentheses' )->rawParams(
                        $lang->pipeList(
                                array( $pagingLinks['first'],
-                               $pagingLinks['last'] )
+                                       $pagingLinks['last'] )
                        ) )->escaped() . " " .
                        wfMsgHtml( 'viewprevnext', $pagingLinks['prev'],
-                       $pagingLinks['next'], $limits );
+                               $pagingLinks['next'], $limits );
 
                if( !is_array( $this->getIndexField() ) ) {
                        # Early return to avoid undue nesting
@@ -787,9 +793,11 @@ abstract class ReverseChronologicalPager extends IndexPager {
        function getDateCond( $year, $month ) {
                $year = intval( $year );
                $month = intval( $month );
+
                // Basic validity checks
                $this->mYear = $year > 0 ? $year : false;
                $this->mMonth = ( $month > 0 && $month < 13 ) ? $month : false;
+
                // Given an optional year and month, we need to generate a timestamp
                // to use as "WHERE rev_timestamp <= result"
                // Examples: year = 2006 equals < 20070101 (+000000)
@@ -798,6 +806,7 @@ abstract class ReverseChronologicalPager extends IndexPager {
                if ( !$this->mYear && !$this->mMonth ) {
                        return;
                }
+
                if ( $this->mYear ) {
                        $year = $this->mYear;
                } else {
@@ -808,6 +817,7 @@ abstract class ReverseChronologicalPager extends IndexPager {
                                $year--;
                        }
                }
+
                if ( $this->mMonth ) {
                        $month = $this->mMonth + 1;
                        // For December, we want January 1 of the next year
@@ -820,14 +830,18 @@ abstract class ReverseChronologicalPager extends IndexPager {
                        $month = 1;
                        $year++;
                }
+
                // Y2K38 bug
                if ( $year > 2032 ) {
                        $year = 2032;
                }
+
                $ymd = (int)sprintf( "%04d%02d01", $year, $month );
+
                if ( $ymd > 20320101 ) {
                        $ymd = 20320101;
                }
+
                $this->mOffset = $this->mDb->timestamp( "${ymd}000000" );
        }
 }
@@ -895,7 +909,7 @@ abstract class TablePager extends IndexPager {
                                        $image = htmlspecialchars( "$wgStylePath/common/images/$image" );
                                        $link = $this->makeLink(
                                                "<img width=\"12\" height=\"12\" alt=\"$alt\" src=\"$image\" />" .
-                                               htmlspecialchars( $name ), $query );
+                                                       htmlspecialchars( $name ), $query );
                                        $s .= "<th class=\"$sortClass\">$link</th>\n";
                                } else {
                                        $s .= '<th>' . $this->makeLink( htmlspecialchars( $name ), $query ) . "</th>\n";
index 511443f..702ca7e 100644 (file)
@@ -1190,12 +1190,10 @@ class SkinTemplate extends Skin {
                                'href' => self::makeSpecialUrlSubpage( 'Contributions', $rootUser )
                        );
 
-                       if ( $user->isLoggedIn() ) {
-                               $logPage = SpecialPage::getTitleFor( 'Log' );
-                               $nav_urls['log'] = array(
-                                       'href' => $logPage->getLocalUrl( array( 'user' => $rootUser ) )
-                               );
-                       }
+                       $logPage = SpecialPage::getTitleFor( 'Log' );
+                       $nav_urls['log'] = array(
+                               'href' => $logPage->getLocalUrl( array( 'user' => $rootUser ) )
+                       );
 
                        if ( $this->getUser()->isAllowed( 'block' ) ) {
                                $nav_urls['blockip'] = array(
index a6719c8..40856ca 100644 (file)
@@ -294,6 +294,7 @@ class DeletedContributionsPage extends SpecialPage {
                        $out->addHTML( $this->getForm( '' ) );
                        return;
                }
+               $this->getSkin()->setRelevantUser( $userObj );
 
                $target = $userObj->getName();
                $out->addSubtitle( $this->getSubTitle( $userObj ) );
index 393cf7e..6b817d2 100644 (file)
@@ -141,13 +141,13 @@ class MovePageForm extends UnlistedSpecialPage {
                        && $newTitle->quickUserCan( 'delete', $user )
                ) {
                        $out->addWikiMsg( 'delete_and_move_text', $newTitle->getPrefixedText() );
-                       $movepagebtn = wfMsg( 'delete_and_move' );
+                       $movepagebtn = $this->msg( 'delete_and_move' )->text();
                        $submitVar = 'wpDeleteAndMove';
                        $confirm = "
                                <tr>
                                        <td></td>
                                        <td class='mw-input'>" .
-                                               Xml::checkLabel( wfMsg( 'delete_and_move_confirm' ), 'wpConfirm', 'wpConfirm' ) .
+                                               Xml::checkLabel( $this->msg( 'delete_and_move_confirm' )->text(), 'wpConfirm', 'wpConfirm' ) .
                                        "</td>
                                </tr>";
                        $err = array();
@@ -157,7 +157,7 @@ class MovePageForm extends UnlistedSpecialPage {
                        }
                        $out->addWikiMsg( $wgFixDoubleRedirects ? 'movepagetext' :
                                'movepagetext-noredirectfixer' );
-                       $movepagebtn = wfMsg( 'movepagebtn' );
+                       $movepagebtn = $this->msg( 'movepagebtn' )->text();
                        $submitVar = 'wpMove';
                        $confirm = false;
                }
@@ -249,11 +249,11 @@ class MovePageForm extends UnlistedSpecialPage {
                $out->addHTML(
                         Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
                         Xml::openElement( 'fieldset' ) .
-                        Xml::element( 'legend', null, wfMsg( 'move-page-legend' ) ) .
+                        Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) .
                         Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-movepage-table' ) ) .
                         "<tr>
                                <td class='mw-label'>" .
-                                       wfMsgHtml( 'movearticle' ) .
+                                       $this->msg( 'movearticle' )->escaped() .
                                "</td>
                                <td class='mw-input'>
                                        <strong>{$oldTitleLink}</strong>
@@ -261,7 +261,7 @@ class MovePageForm extends UnlistedSpecialPage {
                        </tr>
                        <tr>
                                <td class='mw-label'>" .
-                                       Xml::label( wfMsg( 'newtitle' ), 'wpNewTitleMain' ) .
+                                       Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) .
                                "</td>
                                <td class='mw-input'>" .
                                        Html::namespaceSelector(
@@ -278,7 +278,7 @@ class MovePageForm extends UnlistedSpecialPage {
                        </tr>
                        <tr>
                                <td class='mw-label'>" .
-                                       Xml::label( wfMsg( 'movereason' ), 'wpReason' ) .
+                                       Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) .
                                "</td>
                                <td class='mw-input'>" .
                                        Html::element( 'textarea', array( 'name' => 'wpReason', 'id' => 'wpReason', 'cols' => 60, 'rows' => 2,
@@ -292,7 +292,7 @@ class MovePageForm extends UnlistedSpecialPage {
                                <tr>
                                        <td></td>
                                        <td class='mw-input'>" .
-                                               Xml::checkLabel( wfMsg( 'movetalk' ), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) .
+                                               Xml::checkLabel( $this->msg( 'movetalk' )->text(), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) .
                                        "</td>
                                </tr>"
                        );
@@ -303,7 +303,7 @@ class MovePageForm extends UnlistedSpecialPage {
                                <tr>
                                        <td></td>
                                        <td class='mw-input' >" .
-                                               Xml::checkLabel( wfMsg( 'move-leave-redirect' ), 'wpLeaveRedirect',
+                                               Xml::checkLabel( $this->msg( 'move-leave-redirect' )->text(), 'wpLeaveRedirect',
                                                        'wpLeaveRedirect', $this->leaveRedirect ) .
                                        "</td>
                                </tr>"
@@ -315,7 +315,7 @@ class MovePageForm extends UnlistedSpecialPage {
                                <tr>
                                        <td></td>
                                        <td class='mw-input' >" .
-                                               Xml::checkLabel( wfMsg( 'fix-double-redirects' ), 'wpFixRedirects',
+                                               Xml::checkLabel( $this->msg( 'fix-double-redirects' )->text(), 'wpFixRedirects',
                                                        'wpFixRedirects', $this->fixRedirects ) .
                                        "</td>
                                </tr>"
@@ -335,15 +335,11 @@ class MovePageForm extends UnlistedSpecialPage {
                                        array( 'id' => 'wpMovesubpages' )
                                ) . '&#160;' .
                                Xml::tags( 'label', array( 'for' => 'wpMovesubpages' ),
-                                       wfMsgExt(
+                                       $this->msg(
                                                ( $this->oldTitle->hasSubpages()
                                                        ? 'move-subpages'
-                                                       : 'move-talk-subpages' ),
-                                               array( 'parseinline' ),
-                                               $this->getLanguage()->formatNum( $wgMaximumMovedPages ),
-                                               # $2 to allow use of PLURAL in message.
-                                               $wgMaximumMovedPages
-                                       )
+                                                       : 'move-talk-subpages' )
+                                               )->numParams( $wgMaximumMovedPages )->params( $wgMaximumMovedPages )->parse()
                                ) .
                                        "</td>
                                </tr>"
@@ -358,7 +354,7 @@ class MovePageForm extends UnlistedSpecialPage {
                        <tr>
                                <td></td>
                                <td class='mw-input'>" .
-                                       Xml::checkLabel( wfMsg( 'move-watch' ), 'wpWatch', 'watch', $watchChecked ) .
+                                       Xml::checkLabel( $this->msg( 'move-watch' )->text(), 'wpWatch', 'watch', $watchChecked ) .
                                "</td>
                        </tr>");
                }
@@ -421,7 +417,7 @@ class MovePageForm extends UnlistedSpecialPage {
                                return;
                        }
 
-                       $reason = wfMessage( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
+                       $reason = $this->msg( 'delete_and_move_reason', $ot )->inContentLanguage()->text();
 
                        // Delete an associated image if there is
                        if ( $nt->getNamespace() == NS_FILE ) {
@@ -472,7 +468,7 @@ class MovePageForm extends UnlistedSpecialPage {
                $newText = $nt->getPrefixedText();
 
                $msgName = $createRedirect ? 'movepage-moved-redirect' : 'movepage-moved-noredirect';
-               $out->addHTML( wfMessage( 'movepage-moved' )->rawParams( $oldLink,
+               $out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
                        $newLink )->params( $oldText, $newText )->parseAsBlock() );
                $out->addWikiMsg( $msgName );
 
@@ -562,15 +558,15 @@ class MovePageForm extends UnlistedSpecialPage {
                        $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
                        if( !$newSubpage ) {
                                $oldLink = Linker::linkKnown( $oldSubpage );
-                               $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink,
-                                       htmlspecialchars(Title::makeName( $newNs, $newPageName )));
+                               $extraOutput []= $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink
+                                       )->params( Title::makeName( $newNs, $newPageName ) )->escaped();
                                continue;
                        }
 
                        # This was copy-pasted from Renameuser, bleh.
                        if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
                                $link = Linker::linkKnown( $newSubpage );
-                               $extraOutput []= wfMsgHtml( 'movepage-page-exists', $link );
+                               $extraOutput []= $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
                        } else {
                                $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
                                if( $success === true ) {
@@ -584,16 +580,16 @@ class MovePageForm extends UnlistedSpecialPage {
                                                array( 'redirect' => 'no' )
                                        );
                                        $newLink = Linker::linkKnown( $newSubpage );
-                                       $extraOutput []= wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink );
+                                       $extraOutput []= $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped();
                                        ++$count;
                                        if( $count >= $wgMaximumMovedPages ) {
-                                               $extraOutput []= wfMsgExt( 'movepage-max-pages', array( 'parsemag', 'escape' ), $this->getLanguage()->formatNum( $wgMaximumMovedPages ) );
+                                               $extraOutput []= $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped();
                                                break;
                                        }
                                } else {
                                        $oldLink = Linker::linkKnown( $oldSubpage );
                                        $newLink = Linker::link( $newSubpage );
-                                       $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink, $newLink );
+                                       $extraOutput []= $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped();
                                }
                        }
 
index 7feec9d..ab3182d 100644 (file)
@@ -1463,6 +1463,7 @@ It appears to have been deleted.',
 It already exists.',
 'addsection-preload'               => '', # do not translate or duplicate this message to other languages
 'addsection-editintro'             => '', # do not translate or duplicate this message to other languages
+'defaultmessagetext'               => 'Default message text',
 
 # Parser/template warnings
 'expensive-parserfunction-warning'        => "'''Warning:''' This page contains too many expensive parser function calls.
index f8577b0..11b0393 100644 (file)
@@ -1001,6 +1001,7 @@ Please report at [[Support]] if you are unable to properly translate this messag
 'recreate-moveddeleted-warn' => 'Warning shown when creating a page which has already been deleted. See for example [[Test]].',
 'moveddeleted-notice' => 'Shown on top of a deleted page in normal view modus ([http://translatewiki.net/wiki/Test example]).',
 'edit-conflict' => "An 'Edit conflict' happens when more than one edit is being made to a page at the same time. This would usually be caused by separate individuals working on the same page. However, if the system is slow, several edits from one individual could back up and attempt to apply simultaneously - causing the conflict.",
+'defaultmessagetext' => 'Header in diff view, when using "Show Changes" on an default message, which shows a diff against the default message text',
 
 # Parser/template warnings
 'expensive-parserfunction-warning' => 'On some (expensive) [[MetaWikipedia:Help:ParserFunctions|parser functions]] (e.g. <code><nowiki>{{#ifexist:}}</nowiki></code>) there is a limit of how many times it may be used. This is an error message shown when the limit is exceeded.
index 230f397..3c74403 100644 (file)
@@ -675,6 +675,7 @@ $wgMessageStructure = array(
                'edit-already-exists',
                'addsection-preload',
                'addsection-editintro',
+               'defaultmessagetext',
        ),
        'parserwarnings' => array(
                'expensive-parserfunction-warning',
index 84c0fc2..372a6db 100644 (file)
@@ -33,8 +33,6 @@ class ApiBlockTest extends ApiTestCase {
         * Root cause is https://gerrit.wikimedia.org/r/3434
         * Which made the Block/Unblock API to actually verify the token
         * previously always considered valid (bug 34212).
-        *
-        * @group Broken
         */
        function testMakeNormalBlock() {