r25037 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25036‎ | r25037 | r25038 >
Date:07:08, 22 August 2007
Author:robchurch
Status:old
Tags:
Comment:
(bug 10985) Special:DoubleRedirects was omitting "fixed" results when cached, leading to inconsistent paging behaviour - if the query is too expensive to run live, then it shouldn't be run in miser mode either (which is what was happening)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialDoubleRedirects.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1570,7 +1570,7 @@
15711571
15721572 'doubleredirects' => 'Double redirects',
15731573 'doubleredirects-summary' => '', # only translate this message to other languages if you have to change it
1574 -'doubleredirectstext' => 'Each row contains links to the first and second redirect, as well as the target of the second redirect, which is usually "real" target page, which the first redirect should point to.',
 1574+'doubleredirectstext' => 'The following redirects link to other redirect pages:',
15751575
15761576 'brokenredirects' => 'Broken redirects',
15771577 'brokenredirects-summary' => '', # only translate this message to other languages if you have to change it
Index: trunk/phase3/includes/SpecialDoubleRedirects.php
@@ -22,37 +22,29 @@
2323 return wfMsgExt( 'doubleredirectstext', array( 'parse' ) );
2424 }
2525
26 - function getSQLText( &$dbr, $namespace = null, $title = null ) {
27 -
 26+ function getSql() {
 27+ $dbr = wfGetDB( DB_SLAVE );
2828 list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' );
29 -
30 - $limitToTitle = !( $namespace === null && $title === null );
31 - $sql = $limitToTitle ? "SELECT" : "SELECT 'DoubleRedirects' as type," ;
32 - $sql .=
33 - " pa.page_namespace as namespace, pa.page_title as title," .
34 - " pb.page_namespace as nsb, pb.page_title as tb," .
35 - " pc.page_namespace as nsc, pc.page_title as tc" .
36 - " FROM $redirect AS ra, $redirect AS rb, $page AS pa, $page AS pb, $page AS pc" .
37 - " WHERE ra.rd_from=pa.page_id" .
38 - " AND ra.rd_namespace=pb.page_namespace" .
39 - " AND ra.rd_title=pb.page_title" .
40 - " AND rb.rd_from=pb.page_id" .
41 - " AND rb.rd_namespace=pc.page_namespace" .
42 - " AND rb.rd_title=pc.page_title";
43 -
44 - if( $limitToTitle ) {
45 - $encTitle = $dbr->addQuotes( $title );
46 - $sql .= " AND pa.page_namespace=$namespace" .
47 - " AND pa.page_title=$encTitle";
48 - }
49 -
50 - return $sql;
 29+ return "
 30+ SELECT
 31+ 'DoubleRedirects' as type,
 32+ pa.page_namespace as namespace, pa.page_title as title,
 33+ pb.page_namespace as nsb, pb.page_title as tb,
 34+ pc.page_namespace as nsc, pc.page_title as tc
 35+ FROM
 36+ $redirect AS ra,
 37+ $redirect AS rb,
 38+ $page AS pa,
 39+ $page AS pb,
 40+ $page AS pc
 41+ WHERE
 42+ ra.rd_from = pa.page_id
 43+ AND ra.rd_namespace = pb.page_namespace
 44+ AND ra.rd_title = pb.page_title
 45+ AND rb.rd_from = pb.page_id
 46+ AND rb.rd_namespace = pc.page_namespace
 47+ AND rb.rd_title = pc.page_title";
5148 }
52 -
53 - function getSQL() {
54 - $dbr = wfGetDB( DB_SLAVE );
55 - return $this->getSQLText( $dbr );
56 - }
5749
5850 function getOrder() {
5951 return '';
@@ -60,33 +52,30 @@
6153
6254 function formatResult( $skin, $result ) {
6355 global $wgContLang;
 56+ $parts = array();
6457
65 - $fname = 'DoubleRedirectsPage::formatResult';
6658 $titleA = Title::makeTitle( $result->namespace, $result->title );
67 -
68 - if ( $result && !isset( $result->nsb ) ) {
69 - $dbr = wfGetDB( DB_SLAVE );
70 - $sql = $this->getSQLText( $dbr, $result->namespace, $result->title );
71 - $res = $dbr->query( $sql, $fname );
72 - if ( $res ) {
73 - $result = $dbr->fetchObject( $res );
74 - $dbr->freeResult( $res );
75 - }
 59+ $parts[] = $skin->makeKnownLinkObj( $titleA, '', 'redirect=no' );
 60+ $parts[] = '(' . $skin->makeKnownLinkObj(
 61+ $titleA,
 62+ wfMsgHtml( 'qbedit' ),
 63+ 'action=edit&redirect=no'
 64+ ) . ')';
 65+
 66+ // If the report isn't cached, generate some useful additional
 67+ // links to the target page, and *that* page's redirect target
 68+ if( isset( $result->nsb ) ) {
 69+ $parts[] = $wgContLang->getArrow() . $wgContLang->getDirMark();
 70+ $parts[] = $skin->makeKnownLinkObj(
 71+ Title::makeTitle( $result->nsb, $result->tb ),
 72+ '',
 73+ 'redirect=no'
 74+ );
 75+ $parts[] = $wgContLang->getArrow() . $wgContLang->getDirMark();
 76+ $parts[] = $skin->makeKnownLinkObj( Title::makeTitle( $result->nsc, $result->tc ) );
7677 }
77 - if ( !$result ) {
78 - return '';
79 - }
8078
81 - $titleB = Title::makeTitle( $result->nsb, $result->tb );
82 - $titleC = Title::makeTitle( $result->nsc, $result->tc );
83 -
84 - $linkA = $skin->makeKnownLinkObj( $titleA,'', 'redirect=no' );
85 - $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no');
86 - $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' );
87 - $linkC = $skin->makeKnownLinkObj( $titleC );
88 - $arr = $wgContLang->getArrow() . $wgContLang->getDirMark();
89 -
90 - return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" );
 79+ return implode( ' ', $parts );
9180 }
9281 }
9382
@@ -95,10 +84,6 @@
9685 */
9786 function wfSpecialDoubleRedirects() {
9887 list( $limit, $offset ) = wfCheckLimits();
99 -
10088 $sdr = new DoubleRedirectsPage();
101 -
10289 return $sdr->doQuery( $offset, $limit );
103 -
104 -}
105 -
 90+}
\ No newline at end of file
Index: trunk/phase3/RELEASE-NOTES
@@ -396,6 +396,8 @@
397397 lost and transparent pixels to be turned black
398398 * (bug 9339) General error pages were transforming messages and their parameters
399399 in the wrong order
 400+* (bug 10985) Special:DoubleRedirects was omitting "fixed" results when cached,
 401+ leading to inconsistent paging behaviour
400402
401403 == API changes since 1.10 ==
402404

Follow-up revisions

RevisionCommit summaryAuthorDate
r25075Revert r25037 -- just removes functionality from Special:DoubleRedirects inst...brion21:52, 22 August 2007
r25109Merged revisions 25016-25108 via svnmerge from...david07:30, 24 August 2007
r25246* (bug 10985) Compromise solution; strike out resolved cached entries to avoi...robchurch16:59, 28 August 2007
r25303Merged revisions 25215-25302 via svnmerge from...david07:10, 30 August 2007

Status & tagging log