Various fixes to Special:Mostlinked.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 10 May 2012 19:51:50 +0000 (21:51 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 10 May 2012 19:57:22 +0000 (21:57 +0200)
* Show descriptive error message on invalid title
* Call methods directly on ResultWrapper instead of DatabaseBase

Change-Id: Ia437e73546ce664395f07c4a10bad6f04fcfb5d7

includes/specials/SpecialMostlinked.php

index a16f087..ef2cf74 100644 (file)
@@ -62,12 +62,12 @@ class MostlinkedPage extends QueryPage {
         * @param $res
         */
        function preprocessResults( $db, $res ) {
-               if( $db->numRows( $res ) > 0 ) {
+               if ( $res->numRows() > 0 ) {
                        $linkBatch = new LinkBatch();
                        foreach ( $res as $row ) {
                                $linkBatch->add( $row->namespace, $row->title );
                        }
-                       $db->dataSeek( $res, 0 );
+                       $res->seek( 0 );
                        $linkBatch->execute();
                }
        }
@@ -94,7 +94,8 @@ class MostlinkedPage extends QueryPage {
        function formatResult( $skin, $result ) {
                $title = Title::makeTitleSafe( $result->namespace, $result->title );
                if ( !$title ) {
-                       return '<!-- ' . htmlspecialchars( "Invalid title: [[$title]]" ) . ' -->';
+                       return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
+                               Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
                }
                $link = Linker::link( $title );
                $wlh = $this->makeWlhLink( $title,