Add ArchivedFile::selectFields() and use it
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 9 Feb 2013 14:59:13 +0000 (15:59 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 9 Feb 2013 14:59:13 +0000 (15:59 +0100)
Change-Id: Ia19d7bc1eb2bf77f1aca9d3891cebf57e45c030b

includes/filerepo/file/ArchivedFile.php
includes/filerepo/file/LocalFile.php
includes/revisiondelete/RevisionDelete.php
includes/specials/SpecialUndelete.php

index b02d92b..d6031c7 100644 (file)
@@ -137,27 +137,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 );
-                       $row = $dbr->selectRow( 'filearchive',
-                               array(
-                                       'fa_id',
-                                       'fa_name',
-                                       'fa_archive_name',
-                                       'fa_storage_key',
-                                       'fa_storage_group',
-                                       'fa_size',
-                                       'fa_bits',
-                                       'fa_width',
-                                       'fa_height',
-                                       'fa_metadata',
-                                       'fa_media_type',
-                                       'fa_major_mime',
-                                       'fa_minor_mime',
-                                       'fa_description',
-                                       'fa_user',
-                                       'fa_user_text',
-                                       'fa_timestamp',
-                                       'fa_deleted',
-                                       'fa_sha1' ),
+                       $row = $dbr->selectRow(
+                               'filearchive',
+                               self::selectFields(),
                                $conds,
                                __METHOD__,
                                array( 'ORDER BY' => 'fa_timestamp DESC')
@@ -190,6 +172,34 @@ class ArchivedFile {
                return $file;
        }
 
+       /**
+        * Fields in the filearchive table
+        * @return array
+        */
+       static function selectFields() {
+               return array(
+                       'fa_id',
+                       'fa_name',
+                       'fa_archive_name',
+                       'fa_storage_key',
+                       'fa_storage_group',
+                       'fa_size',
+                       'fa_bits',
+                       'fa_width',
+                       'fa_height',
+                       'fa_metadata',
+                       'fa_media_type',
+                       'fa_major_mime',
+                       'fa_minor_mime',
+                       'fa_description',
+                       'fa_user',
+                       'fa_user_text',
+                       'fa_timestamp',
+                       'fa_deleted',
+                       'fa_sha1',
+               );
+       }
+
        /**
         * Load ArchivedFile object fields from a DB row.
         *
index 0ddebc9..b9d7ff6 100644 (file)
@@ -2128,7 +2128,9 @@ class LocalFileRestoreBatch {
                        $conditions[] = 'fa_id IN (' . $dbw->makeList( $this->ids ) . ')';
                }
 
-               $result = $dbw->select( 'filearchive', '*',
+               $result = $dbw->select(
+                       'filearchive',
+                       ArchivedFile::selectFields(),
                        $conditions,
                        __METHOD__,
                        array( 'ORDER BY' => 'fa_timestamp DESC' )
index 5340cb9..2ade611 100644 (file)
@@ -695,7 +695,9 @@ class RevDel_ArchivedFileList extends RevDel_FileList {
         */
        public function doQuery( $db ) {
                $ids = array_map( 'intval', $this->ids );
-               return $db->select( 'filearchive', '*',
+               return $db->select(
+                       'filearchive',
+                       ArchivedFile::selectFields(),
                        array(
                                'fa_name' => $this->title->getDBkey(),
                                'fa_id'   => $ids
index cf95994..afc41bf 100644 (file)
@@ -156,27 +156,9 @@ class PageArchive {
        function listFiles() {
                if( $this->title->getNamespace() == NS_FILE ) {
                        $dbr = wfGetDB( DB_SLAVE );
-                       $res = $dbr->select( 'filearchive',
-                               array(
-                                       'fa_id',
-                                       'fa_name',
-                                       'fa_archive_name',
-                                       'fa_storage_key',
-                                       'fa_storage_group',
-                                       'fa_size',
-                                       'fa_width',
-                                       'fa_height',
-                                       'fa_bits',
-                                       'fa_metadata',
-                                       'fa_media_type',
-                                       'fa_major_mime',
-                                       'fa_minor_mime',
-                                       'fa_description',
-                                       'fa_user',
-                                       'fa_user_text',
-                                       'fa_timestamp',
-                                       'fa_deleted',
-                                       'fa_sha1' ),
+                       $res = $dbr->select(
+                               'filearchive',
+                               ArchivedFile::selectFields(),
                                array( 'fa_name' => $this->title->getDBkey() ),
                                __METHOD__,
                                array( 'ORDER BY' => 'fa_timestamp DESC' ) );