r61382 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61381‎ | r61382 | r61383 >
Date:19:48, 22 January 2010
Author:demon
Status:resolved
Tags:
Comment:
Clarify parameters to wfFindFile and wfLocalFile, and return caveat to the "This always returns files" comment
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListfiles.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2954,6 +2954,7 @@
29552955 /**
29562956 * Find a file.
29572957 * Shortcut for RepoGroup::singleton()->findFile()
 2958+ * @param $title Either a string or Title object
29582959 * @param $options Associative array of options:
29592960 * time: requested time for an archived image, or false for the
29602961 * current version. An image object will be returned which was
@@ -2976,6 +2977,8 @@
29772978 /**
29782979 * Get an object referring to a locally registered file.
29792980 * Returns a valid placeholder object if the file does not exist.
 2981+ * @param $title Either a string or Title object
 2982+ * @return File, or null if passed an invalid Title
29802983 */
29812984 function wfLocalFile( $title ) {
29822985 return RepoGroup::singleton()->getLocalRepo()->newFile( $title );
Index: trunk/phase3/includes/specials/SpecialListfiles.php
@@ -133,6 +133,10 @@
134134 $name = $this->mCurrentRow->img_name;
135135 $link = $this->getSkin()->linkKnown( Title::makeTitle( NS_FILE, $name ), $value );
136136 $image = wfLocalFile( $value );
 137+ if( !$image ) {
 138+ wfDebug( __METHOD__ . " was passed a bogus title '$value'" );
 139+ return '';
 140+ }
137141 $url = $image->getURL();
138142 $download = Xml::element('a', array( 'href' => $url ), $imgfile );
139143 return "$link ($download)";

Follow-up revisions

RevisionCommit summaryAuthorDate
r61384Revert part of r61382, unrelated changedemon19:50, 22 January 2010

Status & tagging log