Merge "Remove useless method overriding"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 16 Nov 2013 22:44:55 +0000 (22:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 16 Nov 2013 22:44:55 +0000 (22:44 +0000)
RELEASE-NOTES-1.23
includes/EditPage.php
includes/GlobalFunctions.php
includes/PageQueryPage.php
includes/SpecialPage.php
includes/actions/RevisiondeleteAction.php
includes/content/TextContent.php
includes/specials/SpecialLinkSearch.php
includes/specials/SpecialRevisiondelete.php
tests/phpunit/includes/SpecialPageTest.php [new file with mode: 0644]

index d7c252a..c5791ba 100644 (file)
@@ -51,6 +51,7 @@ production.
   behavior of several other features where (bogus) section edit links will
   disappear, such as file description pages loaded via $wgUseInstantCommons or
   pages transcluded cross-wiki via $wgEnableScaryTranscluding.
+* (bug 56912) Show correct link color on cached result of Special:DeadendPages.
 
 === API changes in 1.23 ===
 * (bug 54884) action=parse&prop=categories now indicates hidden and missing
index 68691c5..9a68ab3 100644 (file)
@@ -3155,6 +3155,10 @@ HTML
                                return $previewHTML;
                        }
 
+                       # provide a anchor link to the editform
+                       $continueEditing = '<span class="mw-continue-editing">' .
+                               '[[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' .
+                               wfMessage( 'continue-editing' )->text() . ']]</span>';
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
                                        $note = wfMessage( 'token_suffix_mismatch' )->plain();
@@ -3165,8 +3169,7 @@ HTML
                        } elseif ( $this->incompleteForm ) {
                                $note = wfMessage( 'edit_form_incomplete' )->plain();
                        } else {
-                               $note = wfMessage( 'previewnote' )->plain() .
-                                       ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text() . ']]';
+                               $note = wfMessage( 'previewnote' )->plain() . ' ' . $continueEditing;
                        }
 
                        $parserOptions = $this->mArticle->makeParserOptions( $this->mArticle->getContext() );
@@ -3195,7 +3198,9 @@ HTML
                                # Used messages to make sure grep find them:
                                # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
                                if ( $level && $format ) {
-                                       $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage( "{$level}{$format}preview" )->text() . "</div>";
+                                       $note = "<div id='mw-{$level}{$format}preview'>" .
+                                               wfMessage( "{$level}{$format}preview" )->text() .
+                                               ' ' . $continueEditing . "</div>";
                                }
                        }
 
index 1eb5c3e..688300a 100644 (file)
@@ -496,17 +496,18 @@ function wfAppendQuery( $url, $query ) {
  */
 function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
        global $wgServer, $wgCanonicalServer, $wgInternalServer, $wgRequest;
-       $serverUrl = $wgServer;
        if ( $defaultProto === PROTO_CANONICAL ) {
                $serverUrl = $wgCanonicalServer;
-       }
-       // Make $wgInternalServer fall back to $wgServer if not set
-       if ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) {
+       } elseif ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) {
+               // Make $wgInternalServer fall back to $wgServer if not set
                $serverUrl = $wgInternalServer;
+       } else {
+               $serverUrl = $wgServer;
+               if ( $defaultProto === PROTO_CURRENT ) {
+                       $defaultProto = $wgRequest->getProtocol() . '://';
+               }
        }
-       if ( $defaultProto === PROTO_CURRENT ) {
-               $defaultProto = $wgRequest->getProtocol() . '://';
-       }
+
 
        // Analyze $serverUrl to obtain its protocol
        $bits = wfParseUrl( $serverUrl );
index 61a535d..02a883a 100644 (file)
  * @ingroup SpecialPage
  */
 abstract class PageQueryPage extends QueryPage {
+       /**
+        * Run a LinkBatch to pre-cache LinkCache information,
+        * like page existence and information for stub color and redirect hints.
+        * This should be done for live data and cached data.
+        *
+        * @param $db DatabaseBase connection
+        * @param ResultWrapper $res
+        */
+       public function preprocessResults( $db, $res ) {
+               if ( !$res->numRows() ) {
+                       return;
+               }
+
+               $batch = new LinkBatch();
+               foreach ( $res as $row ) {
+                       $batch->add( $row->namespace, $row->title );
+               }
+               $batch->execute();
+
+               $res->seek( 0 );
+       }
+
        /**
         * Format the result as a simple link to the page
         *
@@ -41,7 +63,7 @@ abstract class PageQueryPage extends QueryPage {
 
                if ( $title instanceof Title ) {
                        $text = $wgContLang->convert( $title->getPrefixedText() );
-                       return Linker::linkKnown( $title, htmlspecialchars( $text ) );
+                       return Linker::link( $title, htmlspecialchars( $text ) );
                } else {
                        return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
                                Linker::getInvalidTitleDescription( $this->getContext(), $row->namespace, $row->title ) );
index a6195fc..20571d7 100644 (file)
@@ -259,11 +259,7 @@ class SpecialPage {
         */
        public static function getTitleFor( $name, $subpage = false, $fragment = '' ) {
                $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
-               if ( $name ) {
-                       return Title::makeTitle( NS_SPECIAL, $name, $fragment );
-               } else {
-                       throw new MWException( "Invalid special page name \"$name\"" );
-               }
+               return Title::makeTitle( NS_SPECIAL, $name, $fragment );
        }
 
        /**
index 2949fa9..1803629 100644 (file)
@@ -49,6 +49,7 @@ class RevisiondeleteAction extends FormlessAction {
        public function show() {
                $special = SpecialPageFactory::getPage( 'Revisiondelete' );
                $special->setContext( $this->getContext() );
+               $special->getContext()->setTitle( $special->getTitle() );
                $special->run( '' );
        }
 }
index f66dacd..87ebc9f 100644 (file)
@@ -156,14 +156,14 @@ class TextContent extends AbstractContent {
        /**
         * Diff this content object with another content object.
         *
-        * @since 1.21diff
+        * @since 1.21
         *
         * @param $that Content: The other content object to compare this content
         * object to.
         * @param $lang Language: The language object to use for text segmentation.
         *    If not given, $wgContentLang is used.
         *
-        * @return DiffResult: A diff representing the changes that would have to be
+        * @return Diff A diff representing the changes that would have to be
         *    made to this content object to make it equal to $that.
         */
        public function diff( Content $that, Language $lang = null ) {
@@ -178,7 +178,7 @@ class TextContent extends AbstractContent {
                }
 
                $otext = $this->getNativeData();
-               $ntext = $this->getNativeData();
+               $ntext = $that->getNativeData();
 
                # Note: Use native PHP diff, external engines don't give us abstract output
                $ota = explode( "\n", $lang->segmentForDiff( $otext ) );
index 5b0c56e..ed6e2a4 100644 (file)
@@ -73,14 +73,17 @@ class LinkSearchPage extends QueryPage {
                        // For protocols without '//' like 'mailto:'
                        $protocol = substr( $target2, 0, $pr_cl + 1 );
                        $target2 = substr( $target2, $pr_cl + 1 );
-               } elseif ( $protocol == '' && $target2 != '' ) {
+               } elseif ( $target2 != '' ) {
                        // default
                        $protocol = 'http://';
                }
                if ( $protocol != '' && !in_array( $protocol, $protocols_list ) ) {
-                       // unsupported protocol, show original search request
+                       // Unsupported protocol, show original search request
                        $target2 = $target;
-                       $protocol = '';
+                       // Since links with unsupported protocols don't end up in
+                       // externallinks, assume $protocol is actually part of a link
+                       // containing ':' or '//' and default to http as above.
+                       $protocol = 'http://';
                }
 
                $out->addWikiMsg(
index 825be6c..87705a8 100644 (file)
@@ -194,6 +194,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        protected function showConvenienceLinks() {
                # Give a link to the logs/hist for this page
                if ( $this->targetObj ) {
+                       // Also set header tabs to be for the target.
+                       $this->getSkin()->setRelevantTitle( $this->targetObj );
+
                        $links = array();
                        $links[] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Log' ),
diff --git a/tests/phpunit/includes/SpecialPageTest.php b/tests/phpunit/includes/SpecialPageTest.php
new file mode 100644 (file)
index 0000000..fb8f7ad
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * @covers SpecialPage
+ *
+ * @group Database
+ *
+ * @licence GNU GPL v2+
+ * @author Katie Filbert < aude.wiki@gmail.com >
+ */
+class SpecialPageTest extends MediaWikiTestCase {
+
+       public function setUp() {
+               parent::setUp();
+
+               $this->setMwGlobals( array(
+                       'wgContLang' => Language::factory( 'en' )
+               ) );
+       }
+
+       /**
+        * @dataProvider getTitleForProvider
+        */
+       public function testGetTitleFor( $expectedName, $name ) {
+               $title = SpecialPage::getTitleFor( $name );
+               $expected = Title::makeTitle( NS_SPECIAL, $expectedName );
+               $this->assertEquals( $expected, $title );
+       }
+
+       public function getTitleForProvider() {
+               return array(
+                       array( 'UserLogin', 'Userlogin' )
+               );
+       }
+
+       /**
+        * @expectedException PHPUnit_Framework_Error_Notice
+        */
+       public function testInvalidGetTitleFor() {
+               $title = SpecialPage::getTitleFor( 'cat' );
+               $expected = Title::makeTitle( NS_SPECIAL, 'Cat' );
+               $this->assertEquals( $expected, $title );
+       }
+
+       /**
+        * @expectedException PHPUnit_Framework_Error_Notice
+        * @dataProvider getTitleForWithWarningProvider
+        */
+       public function testGetTitleForWithWarning( $expected, $name ) {
+               $title = SpecialPage::getTitleFor( $name );
+               $this->assertEquals( $expected, $title );
+       }
+
+       public function getTitleForWithWarningProvider() {
+               return array(
+                       array( Title::makeTitle( NS_SPECIAL, 'UserLogin' ), 'UserLogin' )
+               );
+       }
+
+}