r87347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87346‎ | r87347 | r87348 >
Date:19:49, 3 May 2011
Author:demon
Status:resolved (Comments)
Tags:
Comment:
(bug 22227) Special:Listfiles no longer throws an error on bogus file entries
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListfiles.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -253,7 +253,8 @@
254254 * (bug 28719) Do not call mLinkHolders __destruct explicitly
255255 * (bug 21196) Article::getContributors() no longer fails on PostgreSQL.
256256 * (bug 28752) XCache doesn't work in CLI mode.
257 -* (bug 28076) Thumbnail height limited to 360 pixels on Special:Listfiles
 257+* (bug 28076) Thumbnail height limited to 360 pixels on Special:Listfiles
 258+* (bug 22227) Special:Listfiles no longer throws an error on bogus file entries
258259
259260 === API changes in 1.18 ===
260261 * (bug 26339) Throw warning when truncating an overlarge API result.
Index: trunk/phase3/includes/specials/SpecialListfiles.php
@@ -197,11 +197,16 @@
198198 if ( $imgfile === null ) $imgfile = wfMsg( 'imgfile' );
199199
200200 $filePage = Title::makeTitle( NS_FILE, $value );
201 - $link = $this->getSkin()->linkKnown( $filePage, htmlspecialchars( $filePage->getText() ) );
202 - $image = wfLocalFile( $value );
203 - $url = $image->getURL();
204 - $download = Xml::element('a', array( 'href' => $url ), $imgfile );
205 - return "$link ($download)";
 201+ if( $filePage ) {
 202+ $link = $this->getSkin()->linkKnown( $filePage, htmlspecialchars( $filePage->getText() ) );
 203+ $download = Xml::element( 'a',
 204+ array( 'href' => wfLocalFile( $filePage )->getURL() ),
 205+ $imgfile
 206+ );
 207+ return "$link ($download)";
 208+ } else {
 209+ return htmlspecialchars( $value );
 210+ }
206211 case 'img_user_text':
207212 if ( $this->mCurrentRow->img_user ) {
208213 $link = $this->getSkin()->link(
@@ -217,7 +222,7 @@
218223 case 'img_description':
219224 return $this->getSkin()->commentBlock( $value, null, false, false );
220225 case 'count':
221 - return intval($value)+1;
 226+ return intval( $value ) + 1;
222227 }
223228 }
224229

Follow-up revisions

RevisionCommit summaryAuthorDate
r89674Followup r87347, bug 22227, use makeTitleSafe.demon18:50, 7 June 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   18:45, 7 June 2011

Title::makeTitle does not validate input and cannot return something resolving to false.

#Comment by Catrope (talk | contribs)   18:46, 7 June 2011

You may want makeTitleSafe() instead, if the input can possibly be invalid.

#Comment by 😂 (talk | contribs)   18:48, 7 June 2011

Yeah, makeTitleSafe(), whoops.

#Comment by Brion VIBBER (talk | contribs)   22:26, 7 June 2011

and fixed in r89674, thanks :D

Status & tagging log