From 6634c4077e25ee1c56de0b15f4ab50a06b299c44 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 13 Dec 2008 19:38:34 +0000 Subject: [PATCH] Make getHistory() a bit more paging friendly --- includes/filerepo/LocalFile.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index f3cf90395f..36f72c1aeb 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -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; } -- 2.20.1