r22716 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22715‎ | r22716 | r22717 >
Date:20:00, 4 June 2007
Author:robchurch
Status:old
Tags:
Comment:
* (bug 10117) Special:Wantedpages doesn't handle invalid titles in result - now prints out a warning inline
* Some refactoring of Special:Wantedpages in general
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialWantedpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialWantedpages.php
@@ -63,46 +63,49 @@
6464 $db->dataSeek( $res, 0 );
6565 }
6666
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 ) {
6975 global $wgLang;
70 -
7176 $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 {
7783 $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 ) );
8286 } 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}";
8589 }
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);
9590 }
9691
9792 /**
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
10298 * @return string
10399 */
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+ }
107110 }
108111
109112 }
Index: trunk/phase3/RELEASE-NOTES
@@ -110,8 +110,9 @@
111111 * (bug 3624) TeX: \ker, \hom, \arg, \dim treated like \sin & \cos
112112 * (bug 10132, 10134) Restore back-compatibility Image::imageUrl() function
113113 * (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]
114116
115 -
116117 == MediaWiki API changes since 1.10 ==
117118
118119 (For ongoing development discussion, see http://www.mediawiki.org/wiki/API)

Follow-up revisions

RevisionCommit summaryAuthorDate
r22747Merged revisions 22716-22746 via svnmerge from...david07:07, 5 June 2007

Status & tagging log