r103758 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103757‎ | r103758 | r103759 >
Date:14:32, 20 November 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWhatlinkshere.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -167,6 +167,8 @@
168168 * The API now respects $wgShowHostnames and won't share the hostname in
169169 severedby if it's set to false
170170 * wlexcludeuser parameter added to ApiFeedWatchlist
 171+* (bug 7304) Links on redirect pages no longer cause the redirect page to show
 172+ up as a redirect to the linked page on Special:Whatlinkshere
171173
172174 === Languages updated in 1.19 ===
173175
Index: trunk/phase3/includes/specials/SpecialWhatlinkshere.php
@@ -119,9 +119,9 @@
120120 'pl_title' => $target->getDBkey(),
121121 );
122122 if( $hideredirs ) {
123 - $plConds['page_is_redirect'] = 0;
 123+ $plConds['rd_from'] = null;
124124 } elseif( $hidelinks ) {
125 - $plConds['page_is_redirect'] = 1;
 125+ $plConds[] = 'rd_from is NOT NULL';
126126 }
127127
128128 $tlConds = array(
@@ -156,24 +156,34 @@
157157 $options[] = 'STRAIGHT_JOIN';
158158
159159 $options['LIMIT'] = $queryLimit;
160 - $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' );
 160+ $fields = array( 'page_id', 'page_namespace', 'page_title', 'rd_from' );
161161
 162+ $joinConds = array( 'redirect' => array( 'LEFT JOIN', array(
 163+ 'rd_from = page_id',
 164+ 'rd_namespace' => $target->getNamespace(),
 165+ 'rd_title' => $target->getDBkey(),
 166+ '(rd_interwiki is NULL) or (rd_interwiki = \'\')'
 167+ )));
 168+
162169 if( $fetchlinks ) {
163170 $options['ORDER BY'] = 'pl_from';
164 - $plRes = $dbr->select( array( 'pagelinks', 'page' ), $fields,
165 - $plConds, __METHOD__, $options );
 171+ $plRes = $dbr->select( array( 'pagelinks', 'page', 'redirect' ), $fields,
 172+ $plConds, __METHOD__, $options,
 173+ $joinConds);
166174 }
167175
168176 if( !$hidetrans ) {
169177 $options['ORDER BY'] = 'tl_from';
170 - $tlRes = $dbr->select( array( 'templatelinks', 'page' ), $fields,
171 - $tlConds, __METHOD__, $options );
 178+ $tlRes = $dbr->select( array( 'templatelinks', 'page', 'redirect' ), $fields,
 179+ $tlConds, __METHOD__, $options,
 180+ $joinConds);
172181 }
173182
174183 if( !$hideimages ) {
175184 $options['ORDER BY'] = 'il_from';
176 - $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields,
177 - $ilConds, __METHOD__, $options );
 185+ $ilRes = $dbr->select( array( 'imagelinks', 'page', 'redirect' ), $fields,
 186+ $ilConds, __METHOD__, $options,
 187+ $joinConds);
178188 }
179189
180190 if( ( !$fetchlinks || !$dbr->numRows($plRes) ) && ( $hidetrans || !$dbr->numRows($tlRes) ) && ( $hideimages || !$dbr->numRows($ilRes) ) ) {
@@ -247,7 +257,7 @@
248258 foreach ( $rows as $row ) {
249259 $nt = Title::makeTitle( $row->page_namespace, $row->page_title );
250260
251 - if ( $row->page_is_redirect && $level < 2 ) {
 261+ if ( $row->rd_from && $level < 2 ) {
252262 $out->addHTML( $this->listItem( $row, $nt, true ) );
253263 $this->showIndirectLinks( $level + 1, $nt, $wgMaxRedirectLinksRetrieved );
254264 $out->addHTML( Xml::closeElement( 'li' ) );
@@ -281,7 +291,7 @@
282292 }
283293 }
284294
285 - if( $row->page_is_redirect ) {
 295+ if( $row->rd_from ) {
286296 $query = array( 'redirect' => 'no' );
287297 } else {
288298 $query = array();
@@ -297,7 +307,7 @@
298308 // Display properties (redirect or template)
299309 $propsText = '';
300310 $props = array();
301 - if ( $row->page_is_redirect )
 311+ if ( $row->rd_from )
302312 $props[] = $msgcache['isredirect'];
303313 if ( $row->is_template )
304314 $props[] = $msgcache['istemplate'];

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r16690* Workaround the redirect bug 7304...yurik03:30, 29 September 2006
r17292Updated info on bug 7304 (redirect table). This relates to checkin r17291.yurik21:40, 29 October 2006

Comments

#Comment by Bawolff (talk | contribs)   21:16, 20 November 2011

Oh wow, I had totally forgotten about that bug and the patch on it. Thanks for applying.

#Comment by Brion VIBBER (talk | contribs)   01:12, 23 November 2011

Nice! Seems to work in some ad-hoc testing.

Status & tagging log