From ba54d888823483c56ff8131602bad5ba21e711b1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 8 Jun 2008 17:39:24 +0000 Subject: [PATCH] * Add OldLocalFile::selectRows() * Add LocalFile::getHistory hook * Do file history quality query all at once rather than per file --- docs/hooks.txt | 8 ++++++++ includes/filerepo/LocalFile.php | 8 +++++++- includes/filerepo/OldLocalFile.php | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 51f52ca7e0..e13c1ee6c5 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -741,6 +741,14 @@ $lang: laguage code (string) 'LoadExtensionSchemaUpdates': called by maintenance/updaters.inc when upgrading database schema +'LocalFile::getHistory': called before file history query performed +$file: the file +$tables: tables +$fields: select fields +$conds: conditions +$opts: query options +$join_conds: JOIN conditions + 'LoginAuthenticateAudit': a login attempt for a valid user account either succeeded or failed. No return data is accepted; this hook is for auditing only. $user: the User object being authenticated against diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 228659c65a..ea84550912 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -621,6 +621,9 @@ class LocalFile extends File function getHistory($limit = null, $start = null, $end = null) { $dbr = $this->repo->getSlaveDB(); + $tables = array('oldimage'); + $join_conds = array(); + $fields = OldLocalFile::selectFields(); $conds = $opts = array(); $conds[] = "oi_name = " . $dbr->addQuotes( $this->title->getDBKey() ); if( $start !== null ) { @@ -633,7 +636,10 @@ class LocalFile extends File $opts['LIMIT'] = $limit; } $opts['ORDER BY'] = 'oi_timestamp DESC'; - $res = $dbr->select('oldimage', '*', $conds, __METHOD__, $opts); + + wfRunHooks( 'LocalFile::getHistory', array( &$this, &$tables, &$fields, &$conds, &$opts, &$join_conds ) ); + + $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $opts, $join_conds ); $r = array(); while( $row = $dbr->fetchObject($res) ) { $r[] = OldLocalFile::newFromRow($row, $this->repo); diff --git a/includes/filerepo/OldLocalFile.php b/includes/filerepo/OldLocalFile.php index 60e90f13d2..89e49c4c1d 100644 --- a/includes/filerepo/OldLocalFile.php +++ b/includes/filerepo/OldLocalFile.php @@ -44,6 +44,29 @@ class OldLocalFile extends LocalFile { return false; } } + + /** + * Fields in the oldimage table + */ + static function selectFields() { + return array( + 'oi_name', + 'oi_archive_name', + 'oi_size', + 'oi_width', + 'oi_height', + 'oi_metadata', + 'oi_bits', + 'oi_media_type', + 'oi_major_mime', + 'oi_minor_mime', + 'oi_description', + 'oi_user', + 'oi_user_text', + 'oi_timestamp', + 'oi_sha1', + ); + } /** * @param Title $title -- 2.20.1