* Add OldLocalFile::selectRows()
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 8 Jun 2008 17:39:24 +0000 (17:39 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 8 Jun 2008 17:39:24 +0000 (17:39 +0000)
* Add LocalFile::getHistory hook
* Do file history quality query all at once rather than per file

docs/hooks.txt
includes/filerepo/LocalFile.php
includes/filerepo/OldLocalFile.php

index 51f52ca..e13c1ee 100644 (file)
@@ -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
index 228659c..ea84550 100644 (file)
@@ -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);
index 60e90f1..89e49c4 100644 (file)
@@ -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