Merge changes Idfc2e2b6,I9b30d602
[lhc/web/wiklou.git] / includes / specials / SpecialBrokenRedirects.php
index 21a098a..97de72a 100644 (file)
  */
 
 /**
- * A special page listing redirects tonon existent page. Those should be
+ * A special page listing redirects to non existent page. Those should be
  * fixed to point to an existing page.
  *
  * @ingroup SpecialPage
  */
-class BrokenRedirectsPage extends PageQueryPage {
+class BrokenRedirectsPage extends QueryPage {
 
        function __construct( $name = 'BrokenRedirects' ) {
                parent::__construct( $name );
        }
 
-       function isExpensive() { return true; }
-       function isSyndicated() { return false; }
-       function sortDescending() { return false; }
+       function isExpensive() {
+               return true;
+       }
+
+       function isSyndicated() {
+               return false;
+       }
+
+       function sortDescending() {
+               return false;
+       }
 
        function getPageHeader() {
-               return wfMsgExt( 'brokenredirectstext', array( 'parse' ) );
+               return $this->msg( 'brokenredirectstext' )->parseAsBlock();
        }
 
        function getQueryInfo() {
                return array(
-                       'tables' => array( 'redirect', 'p1' => 'page',
-                                       'p2' => 'page' ),
-                       'fields' => array( 'p1.page_namespace AS namespace',
-                                       'p1.page_title AS title',
-                                       'rd_namespace',
-                                       'rd_title'
+                       'tables' => array(
+                               'redirect',
+                               'p1' => 'page',
+                               'p2' => 'page',
+                       ),
+                       'fields' => array(
+                               'namespace' => 'p1.page_namespace',
+                               'title' => 'p1.page_title',
+                               'value' => 'p1.page_title',
+                               'rd_namespace',
+                               'rd_title',
                        ),
-                       'conds' => array( 'rd_namespace >= 0',
-                                       'p2.page_namespace IS NULL'
+                       'conds' => array(
+                               // Exclude pages that don't exist locally as wiki pages,
+                               // but aren't "broken" either.
+                               // Special pages and interwiki links
+                               'rd_namespace >= 0',
+                               '(rd_interwiki IS NULL OR rd_interwiki = "")',
+                               'p2.page_namespace IS NULL',
+                       ),
+                       'join_conds' => array(
+                               'p1' => array( 'JOIN', array(
+                                       'rd_from=p1.page_id',
+                               ) ),
+                               'p2' => array( 'LEFT JOIN', array(
+                                       'rd_namespace=p2.page_namespace',
+                                       'rd_title=p2.page_title'
+                               ) ),
                        ),
-                       'join_conds' => array( 'p1' => array( 'LEFT JOIN', array(
-                                               'rd_from=p1.page_id',
-                                       ) ),
-                                       'p2' => array( 'LEFT JOIN', array(
-                                               'rd_namespace=p2.page_namespace',
-                                               'rd_title=p2.page_title'
-                                       ) )
-                       )
                );
        }
 
@@ -77,8 +96,6 @@ class BrokenRedirectsPage extends PageQueryPage {
         * @return String
         */
        function formatResult( $skin, $result ) {
-               global $wgUser, $wgLang;
-
                $fromObj = Title::makeTitle( $result->namespace, $result->title );
                if ( isset( $result->rd_title ) ) {
                        $toObj = Title::makeTitle( $result->rd_namespace, $result->rd_title );
@@ -93,43 +110,43 @@ class BrokenRedirectsPage extends PageQueryPage {
 
                // $toObj may very easily be false if the $result list is cached
                if ( !is_object( $toObj ) ) {
-                       return '<del>' . $skin->link( $fromObj ) . '</del>';
+                       return '<del>' . Linker::link( $fromObj ) . '</del>';
                }
 
-               $from = $skin->linkKnown(
+               $from = Linker::linkKnown(
                        $fromObj,
                        null,
                        array(),
                        array( 'redirect' => 'no' )
                );
                $links = array();
-               $links[] = $skin->linkKnown(
+               $links[] = Linker::linkKnown(
                        $fromObj,
-                       wfMsgHtml( 'brokenredirects-edit' ),
+                       $this->msg( 'brokenredirects-edit' )->escaped(),
                        array(),
                        array( 'action' => 'edit' )
                );
-               $to = $skin->link(
+               $to = Linker::link(
                        $toObj,
                        null,
                        array(),
                        array(),
                        array( 'broken' )
                );
-               $arr = $wgLang->getArrow();
+               $arr = $this->getLanguage()->getArrow();
 
-               $out = $from . wfMsg( 'word-separator' );
+               $out = $from . $this->msg( 'word-separator' )->escaped();
 
-               if( $wgUser->isAllowed( 'delete' ) ) {
-                       $links[] = $skin->linkKnown(
+               if( $this->getUser()->isAllowed( 'delete' ) ) {
+                       $links[] = Linker::linkKnown(
                                $fromObj,
-                               wfMsgHtml( 'brokenredirects-delete' ),
+                               $this->msg( 'brokenredirects-delete' )->escaped(),
                                array(),
                                array( 'action' => 'delete' )
                        );
                }
 
-               $out .= wfMsg( 'parentheses', $wgLang->pipeList( $links ) );
+               $out .= $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList( $links ) )->escaped();
                $out .= " {$arr} {$to}";
                return $out;
        }