Use selectRow when load one ArchivedFile
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 26 Oct 2012 17:51:18 +0000 (19:51 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 26 Oct 2012 17:51:18 +0000 (19:51 +0200)
Change-Id: Ifa0e68bece4e9ad3e1e90ac503a936e61e958cdf

includes/filerepo/file/ArchivedFile.php

index 694623b..e1a8547 100644 (file)
@@ -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;