From 7cf8b3197c58b7c938e33f3eea2e119fa7cf8cf8 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 20 Nov 2011 14:32:59 +0000 Subject: [PATCH] (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. Patch by Bawolff, using the redirect table instead of page_is_redirect to identify redirects --- RELEASE-NOTES-1.19 | 2 ++ includes/specials/SpecialWhatlinkshere.php | 34 ++++++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 8697f30698..f04b0479e1 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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 === diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index a5b605a077..82ad7dfb1a 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -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']; -- 2.20.1