From 07c5db7f403ea3472cc71bdb7f27d662a53f5ffa Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 22 Jan 2010 19:48:10 +0000 Subject: [PATCH] Clarify parameters to wfFindFile and wfLocalFile, and return caveat to the "This always returns files" comment --- includes/GlobalFunctions.php | 3 +++ includes/specials/SpecialListfiles.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 13833033b4..b8916c2fe7 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2954,6 +2954,7 @@ function &wfGetLBFactory() { /** * Find a file. * Shortcut for RepoGroup::singleton()->findFile() + * @param $title Either a string or Title object * @param $options Associative array of options: * time: requested time for an archived image, or false for the * current version. An image object will be returned which was @@ -2976,6 +2977,8 @@ function wfFindFile( $title, $options = array() ) { /** * Get an object referring to a locally registered file. * Returns a valid placeholder object if the file does not exist. + * @param $title Either a string or Title object + * @return File, or null if passed an invalid Title */ function wfLocalFile( $title ) { return RepoGroup::singleton()->getLocalRepo()->newFile( $title ); diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 788009764f..463be895e4 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -133,6 +133,10 @@ class ImageListPager extends TablePager { $name = $this->mCurrentRow->img_name; $link = $this->getSkin()->linkKnown( Title::makeTitle( NS_FILE, $name ), $value ); $image = wfLocalFile( $value ); + if( !$image ) { + wfDebug( __METHOD__ . " was passed a bogus title '$value'" ); + return ''; + } $url = $image->getURL(); $download = Xml::element('a', array( 'href' => $url ), $imgfile ); return "$link ($download)"; -- 2.20.1