(bug 7304) Links on redirect pages no longer cause the redirect page to show up as...
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 20 Nov 2011 14:32:59 +0000 (14:32 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 20 Nov 2011 14:32:59 +0000 (14:32 +0000)
RELEASE-NOTES-1.19
includes/specials/SpecialWhatlinkshere.php

index 8697f30..f04b047 100644 (file)
@@ -167,6 +167,8 @@ production.
 * The API now respects $wgShowHostnames and won't share the hostname in
   severedby if it's set to false
 * wlexcludeuser parameter added to ApiFeedWatchlist
+* (bug 7304) Links on redirect pages no longer cause the redirect page to show
+  up as a redirect to the linked page on Special:Whatlinkshere
 
 === Languages updated in 1.19 ===
 
index a5b605a..82ad7df 100644 (file)
@@ -119,9 +119,9 @@ class SpecialWhatLinksHere extends SpecialPage {
                        'pl_title' => $target->getDBkey(),
                );
                if( $hideredirs ) {
-                       $plConds['page_is_redirect'] = 0;
+                       $plConds['rd_from'] = null;
                } elseif( $hidelinks ) {
-                       $plConds['page_is_redirect'] = 1;
+                       $plConds[] = 'rd_from is NOT NULL';
                }
 
                $tlConds = array(
@@ -156,24 +156,34 @@ class SpecialWhatLinksHere extends SpecialPage {
                $options[] = 'STRAIGHT_JOIN';
 
                $options['LIMIT'] = $queryLimit;
-               $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' );
+               $fields = array( 'page_id', 'page_namespace', 'page_title', 'rd_from' );
+
+               $joinConds = array( 'redirect' => array( 'LEFT JOIN', array(
+                       'rd_from = page_id',
+                       'rd_namespace' => $target->getNamespace(),
+                       'rd_title' => $target->getDBkey(),
+                       '(rd_interwiki is NULL) or (rd_interwiki = \'\')'
+               )));
 
                if( $fetchlinks ) {
                        $options['ORDER BY'] = 'pl_from';
-                       $plRes = $dbr->select( array( 'pagelinks', 'page' ), $fields,
-                               $plConds, __METHOD__, $options );
+                       $plRes = $dbr->select( array( 'pagelinks', 'page', 'redirect' ), $fields,
+                               $plConds, __METHOD__, $options,
+                               $joinConds);
                }
 
                if( !$hidetrans ) {
                        $options['ORDER BY'] = 'tl_from';
-                       $tlRes = $dbr->select( array( 'templatelinks', 'page' ), $fields,
-                               $tlConds, __METHOD__, $options );
+                       $tlRes = $dbr->select( array( 'templatelinks', 'page', 'redirect' ), $fields,
+                               $tlConds, __METHOD__, $options,
+                               $joinConds);
                }
 
                if( !$hideimages ) {
                        $options['ORDER BY'] = 'il_from';
-                       $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields,
-                               $ilConds, __METHOD__, $options );
+                       $ilRes = $dbr->select( array( 'imagelinks', 'page', 'redirect' ), $fields,
+                               $ilConds, __METHOD__, $options,
+                               $joinConds);
                }
 
                if( ( !$fetchlinks || !$dbr->numRows($plRes) ) && ( $hidetrans || !$dbr->numRows($tlRes) ) && ( $hideimages || !$dbr->numRows($ilRes) ) ) {
@@ -247,7 +257,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                foreach ( $rows as $row ) {
                        $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
 
-                       if ( $row->page_is_redirect && $level < 2 ) {
+                       if ( $row->rd_from && $level < 2 ) {
                                $out->addHTML( $this->listItem( $row, $nt, true ) );
                                $this->showIndirectLinks( $level + 1, $nt, $wgMaxRedirectLinksRetrieved );
                                $out->addHTML( Xml::closeElement( 'li' ) );
@@ -281,7 +291,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                        }
                }
 
-               if( $row->page_is_redirect ) {
+               if( $row->rd_from ) {
                        $query = array( 'redirect' => 'no' );
                } else {
                        $query = array();
@@ -297,7 +307,7 @@ class SpecialWhatLinksHere extends SpecialPage {
                // Display properties (redirect or template)
                $propsText = '';
                $props = array();
-               if ( $row->page_is_redirect )
+               if ( $row->rd_from )
                        $props[] = $msgcache['isredirect'];
                if ( $row->is_template )
                        $props[] = $msgcache['istemplate'];