Fixes to Special:Mostlinkedtemplates.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 2 Aug 2012 20:36:45 +0000 (22:36 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Fri, 3 Aug 2012 06:25:53 +0000 (08:25 +0200)
- Don't execute the LinkBatch if there are no rows.
- Checks for invalid titles and output a message
  if this is the case.

Change-Id: Ibd3794fbe165b13f3b386a9dabe4b6fabb7ba1d8

includes/specials/SpecialMostlinkedtemplates.php

index 370ba68..0b587dc 100644 (file)
@@ -79,13 +79,17 @@ class MostlinkedTemplatesPage extends QueryPage {
         * @param $res ResultWrapper
         */
        public function preprocessResults( $db, $res ) {
+               if ( !$res->numRows() ) {
+                       return;
+               }
+
                $batch = new LinkBatch();
                foreach ( $res as $row ) {
                        $batch->add( $row->namespace, $row->title );
                }
                $batch->execute();
-               if( $db->numRows( $res ) > 0 )
-                       $db->dataSeek( $res, 0 );
+
+               $res->seek( 0 );
        }
 
        /**
@@ -96,7 +100,11 @@ class MostlinkedTemplatesPage extends QueryPage {
         * @return String
         */
        public function formatResult( $skin, $result ) {
-               $title = Title::makeTitle( $result->namespace, $result->title );
+               $title = Title::makeTitleSafe( $result->namespace, $result->title );
+               if ( !$title ) {
+                       return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
+                               Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
+               }
 
                return $this->getLanguage()->specialList(
                        Linker::link( $title ),