From 180c74875b3dc0cae848a80cb50b8cce1444012a Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 9 Feb 2013 15:59:13 +0100 Subject: [PATCH] Add ArchivedFile::selectFields() and use it Change-Id: Ia19d7bc1eb2bf77f1aca9d3891cebf57e45c030b --- includes/filerepo/file/ArchivedFile.php | 52 +++++++++++++--------- includes/filerepo/file/LocalFile.php | 4 +- includes/revisiondelete/RevisionDelete.php | 4 +- includes/specials/SpecialUndelete.php | 24 ++-------- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index b02d92b9b3..d6031c78bd 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -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. * diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 0ddebc9a3e..b9d7ff6e59 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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' ) diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index 5340cb9ec0..2ade611a65 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -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 diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index cf9599499f..afc41bf451 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -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' ) ); -- 2.20.1