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')
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.
*
$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' )
*/
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
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' ) );