Add "help" links for Special:BrokenRedirects, Special:DoubleRedirects, and Special...
[lhc/web/wiklou.git] / includes / specials / SpecialDoubleRedirects.php
index ba14c66..fcf1bb2 100644 (file)
@@ -21,7 +21,7 @@
  * @ingroup SpecialPage
  */
 
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\IDatabase;
 
 /**
@@ -122,28 +122,33 @@ class DoubleRedirectsPage extends QueryPage {
                // That does save the bulk of the query cost, but now we need to
                // get a little more detail about each individual entry quickly
                // using the filter of reallyGetQueryInfo.
-               if ( $result && !isset( $result->b_namespace ) ) {
-                       $dbr = wfGetDB( DB_REPLICA );
-                       $qi = $this->reallyGetQueryInfo(
-                               $result->namespace,
-                               $result->title
-                       );
-                       $res = $dbr->select(
-                               $qi['tables'],
-                               $qi['fields'],
-                               $qi['conds'],
-                               __METHOD__
-                       );
-
-                       if ( $res ) {
-                               $result = $dbr->fetchObject( $res );
+               $deep = false;
+               if ( $result ) {
+                       if ( isset( $result->b_namespace ) ) {
+                               $deep = $result;
+                       } else {
+                               $dbr = wfGetDB( DB_REPLICA );
+                               $qi = $this->reallyGetQueryInfo(
+                                       $result->namespace,
+                                       $result->title
+                               );
+                               $res = $dbr->select(
+                                       $qi['tables'],
+                                       $qi['fields'],
+                                       $qi['conds'],
+                                       __METHOD__
+                               );
+
+                               if ( $res ) {
+                                       $deep = $dbr->fetchObject( $res ) ?: false;
+                               }
                        }
                }
 
                $titleA = Title::makeTitle( $result->namespace, $result->title );
 
                $linkRenderer = $this->getLinkRenderer();
-               if ( !$result ) {
+               if ( !$deep ) {
                        return '<del>' . $linkRenderer->makeLink( $titleA, null, [], [ 'redirect' => 'no' ] ) . '</del>';
                }
 
@@ -171,7 +176,7 @@ class DoubleRedirectsPage extends QueryPage {
                        [ 'redirect' => 'no' ]
                );
 
-               $titleB = Title::makeTitle( $result->b_namespace, $result->b_title );
+               $titleB = Title::makeTitle( $deep->b_namespace, $deep->b_title );
                $linkB = $linkRenderer->makeKnownLink(
                        $titleB,
                        null,
@@ -180,10 +185,10 @@ class DoubleRedirectsPage extends QueryPage {
                );
 
                $titleC = Title::makeTitle(
-                       $result->c_namespace,
-                       $result->c_title,
-                       $result->c_fragment,
-                       $result->c_interwiki
+                       $deep->c_namespace,
+                       $deep->c_title,
+                       $deep->c_fragment,
+                       $deep->c_interwiki
                );
                $linkC = $linkRenderer->makeKnownLink( $titleC, $titleC->getFullText() );
 
@@ -193,11 +198,16 @@ class DoubleRedirectsPage extends QueryPage {
                return ( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
        }
 
+       public function execute( $par ) {
+               $this->addHelpLink( 'Help:Redirects' );
+               parent::execute( $par );
+       }
+
        /**
         * Cache page content model and gender distinction for performance
         *
         * @param IDatabase $db
-        * @param ResultWrapper $res
+        * @param IResultWrapper $res
         */
        function preprocessResults( $db, $res ) {
                if ( !$res->numRows() ) {