Index: trunk/phase3/includes/SpecialWantedpages.php |
— | — | @@ -63,46 +63,49 @@ |
64 | 64 | $db->dataSeek( $res, 0 ); |
65 | 65 | } |
66 | 66 | |
67 | | - |
68 | | - function formatResult( $skin, $result ) { |
| 67 | + /** |
| 68 | + * Format an individual result |
| 69 | + * |
| 70 | + * @param Skin $skin Skin to use for UI elements |
| 71 | + * @param object $result Result row |
| 72 | + * @return string |
| 73 | + */ |
| 74 | + public function formatResult( $skin, $result ) { |
69 | 75 | global $wgLang; |
70 | | - |
71 | 76 | $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
72 | | - |
73 | | - if( $this->isCached() ) { |
74 | | - # Check existence; which is stored in the link cache |
75 | | - if( !$title->exists() ) { |
76 | | - # Make a redlink |
| 77 | + if( $title instanceof Title ) { |
| 78 | + if( $this->isCached() ) { |
| 79 | + $pageLink = $title->exists() |
| 80 | + ? '<s>' . $skin->makeLinkObj( $title ) . '</s>' |
| 81 | + : $skin->makeBrokenLinkObj( $title ); |
| 82 | + } else { |
77 | 83 | $pageLink = $skin->makeBrokenLinkObj( $title ); |
78 | | - } else { |
79 | | - # Make a a struck-out normal link |
80 | | - $pageLink = "<s>" . $skin->makeLinkObj( $title ) . "</s>"; |
81 | | - } |
| 84 | + } |
| 85 | + return wfSpecialList( $pageLink, $this->makeWlhLink( $title, $skin, $result ) ); |
82 | 86 | } else { |
83 | | - # Not cached? Don't bother checking existence; it can't |
84 | | - $pageLink = $skin->makeBrokenLinkObj( $title ); |
| 87 | + $tsafe = htmlspecialchars( $result->title ); |
| 88 | + return "Invalid title in result set; {$tsafe}"; |
85 | 89 | } |
86 | | - |
87 | | - # Make a link to "what links here" if it's required |
88 | | - $wlhLink = $this->nlinks |
89 | | - ? $this->makeWlhLink( $title, $skin, |
90 | | - wfMsgExt( 'nlinks', array( 'parsemag', 'escape'), |
91 | | - $wgLang->formatNum( $result->value ) ) ) |
92 | | - : null; |
93 | | - |
94 | | - return wfSpecialList($pageLink, $wlhLink); |
95 | 90 | } |
96 | 91 | |
97 | 92 | /** |
98 | | - * Make a "what links here" link for a specified title |
99 | | - * @param $title Title to make the link for |
100 | | - * @param $skin Skin to use |
101 | | - * @param $text Link text |
| 93 | + * Make a "what links here" link for a specified result if required |
| 94 | + * |
| 95 | + * @param Title $title Title to make the link for |
| 96 | + * @param Skin $skin Skin to use |
| 97 | + * @param object $result Result row |
102 | 98 | * @return string |
103 | 99 | */ |
104 | | - function makeWlhLink( &$title, &$skin, $text ) { |
105 | | - $wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere' ); |
106 | | - return $skin->makeKnownLinkObj( $wlhTitle, $text, 'target=' . $title->getPrefixedUrl() ); |
| 100 | + private function makeWlhLink( $title, $skin, $result ) { |
| 101 | + global $wgLang; |
| 102 | + if( $this->nlinks ) { |
| 103 | + $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); |
| 104 | + $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), |
| 105 | + $wgLang->formatNum( $result->value ) ); |
| 106 | + return $skin->makeKnownLinkObj( $wlh, $label, 'target=' . $title->getPrefixedUrl() ); |
| 107 | + } else { |
| 108 | + return null; |
| 109 | + } |
107 | 110 | } |
108 | 111 | |
109 | 112 | } |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -110,8 +110,9 @@ |
111 | 111 | * (bug 3624) TeX: \ker, \hom, \arg, \dim treated like \sin & \cos |
112 | 112 | * (bug 10132, 10134) Restore back-compatibility Image::imageUrl() function |
113 | 113 | * (bug 10113) Fix double-click for view source on protected pages |
| 114 | +* (bug 10117) Special:Wantedpages doesn't handle invalid titles in result |
| 115 | + set [now prints out a warning] |
114 | 116 | |
115 | | - |
116 | 117 | == MediaWiki API changes since 1.10 == |
117 | 118 | |
118 | 119 | (For ongoing development discussion, see http://www.mediawiki.org/wiki/API) |