Make getHistory() a bit more paging friendly
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 13 Dec 2008 19:38:34 +0000 (19:38 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 13 Dec 2008 19:38:34 +0000 (19:38 +0000)
includes/filerepo/LocalFile.php

index f3cf903..36f72c1 100644 (file)
@@ -640,15 +640,21 @@ class LocalFile extends File
                if( $limit ) {
                        $opts['LIMIT'] = $limit;
                }
-               $opts['ORDER BY'] = 'oi_timestamp DESC';
+               // Search backwards for time > x queries
+               $order = (!$start && $end === "") ? "ASC" : "DESC";
+               $opts['ORDER BY'] = "oi_timestamp $order";
                
-               wfRunHooks( 'LocalFile::getHistory', array( &$this, &$tables, &$fields, &$conds, &$opts, &$join_conds ) );
+               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);
                }
+               if( $order == "ASC" ) {
+                       $r = array_reverse( $r ); // make sure it ends up descending
+               }
                return $r;
        }