From 5f32ede9d10b1468a443de47d6d6e2cd891e1096 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 26 Oct 2012 19:51:18 +0200 Subject: [PATCH] Use selectRow when load one ArchivedFile Change-Id: Ifa0e68bece4e9ad3e1e90ac503a936e61e958cdf --- includes/filerepo/file/ArchivedFile.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index 694623b627..e1a8547895 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -135,8 +135,9 @@ class ArchivedFile { } if( !$this->title || $this->title->getNamespace() == NS_FILE ) { + $this->dataLoaded = true; // set it here, to have also true on miss $dbr = wfGetDB( DB_SLAVE ); - $res = $dbr->select( 'filearchive', + $row = $dbr->selectRow( 'filearchive', array( 'fa_id', 'fa_name', @@ -159,20 +160,18 @@ class ArchivedFile { 'fa_sha1' ), $conds, __METHOD__, - array( 'ORDER BY' => 'fa_timestamp DESC' ) ); - if ( $res == false || $dbr->numRows( $res ) == 0 ) { - // this revision does not exist? + array( 'ORDER BY' => 'fa_timestamp DESC') + ); + if ( !$row ) { + // this revision does not exist? return null; } - $ret = $dbr->resultObject( $res ); - $row = $ret->fetchObject(); // initialize fields for filestore image object $this->loadFromRow( $row ); } else { throw new MWException( 'This title does not correspond to an image page.' ); } - $this->dataLoaded = true; $this->exists = true; return true; -- 2.20.1