Index: trunk/phase3/includes/SpecialDoubleRedirects.php |
— | — | @@ -22,29 +22,37 @@ |
23 | 23 | return wfMsgExt( 'doubleredirectstext', array( 'parse' ) ); |
24 | 24 | } |
25 | 25 | |
26 | | - function getSql() { |
27 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 26 | + function getSQLText( &$dbr, $namespace = null, $title = null ) { |
| 27 | + |
28 | 28 | list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' ); |
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"; |
| 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; |
48 | 51 | } |
| 52 | + |
| 53 | + function getSQL() { |
| 54 | + $dbr = wfGetDB( DB_SLAVE ); |
| 55 | + return $this->getSQLText( $dbr ); |
| 56 | + } |
49 | 57 | |
50 | 58 | function getOrder() { |
51 | 59 | return ''; |
— | — | @@ -52,30 +60,33 @@ |
53 | 61 | |
54 | 62 | function formatResult( $skin, $result ) { |
55 | 63 | global $wgContLang; |
56 | | - $parts = array(); |
57 | 64 | |
| 65 | + $fname = 'DoubleRedirectsPage::formatResult'; |
58 | 66 | $titleA = Title::makeTitle( $result->namespace, $result->title ); |
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 ) ); |
| 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 | + } |
77 | 76 | } |
| 77 | + if ( !$result ) { |
| 78 | + return ''; |
| 79 | + } |
78 | 80 | |
79 | | - return implode( ' ', $parts ); |
| 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}" ); |
80 | 91 | } |
81 | 92 | } |
82 | 93 | |
— | — | @@ -84,6 +95,10 @@ |
85 | 96 | */ |
86 | 97 | function wfSpecialDoubleRedirects() { |
87 | 98 | list( $limit, $offset ) = wfCheckLimits(); |
| 99 | + |
88 | 100 | $sdr = new DoubleRedirectsPage(); |
| 101 | + |
89 | 102 | return $sdr->doQuery( $offset, $limit ); |
90 | | -} |
\ No newline at end of file |
| 103 | + |
| 104 | +} |
| 105 | + |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1572,7 +1572,7 @@ |
1573 | 1573 | |
1574 | 1574 | 'doubleredirects' => 'Double redirects', |
1575 | 1575 | 'doubleredirects-summary' => '', # only translate this message to other languages if you have to change it |
1576 | | -'doubleredirectstext' => 'The following redirects link to other redirect pages:', |
| 1576 | +'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.', |
1577 | 1577 | |
1578 | 1578 | 'brokenredirects' => 'Broken redirects', |
1579 | 1579 | 'brokenredirects-summary' => '', # only translate this message to other languages if you have to change it |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -400,8 +400,6 @@ |
401 | 401 | lost and transparent pixels to be turned black |
402 | 402 | * (bug 9339) General error pages were transforming messages and their parameters |
403 | 403 | in the wrong order |
404 | | -* (bug 10985) Special:DoubleRedirects was omitting "fixed" results when cached, |
405 | | - leading to inconsistent paging behaviour |
406 | 404 | * (bug 9026) Incorrect heading numbering when viewing Special:Statistics with |
407 | 405 | "auto-numbered headings" enabled |
408 | 406 | * Fixed invalid XHTML in Special:Upload |