From: Aaron Schulz Date: Sat, 13 Dec 2008 19:38:34 +0000 (+0000) Subject: Make getHistory() a bit more paging friendly X-Git-Tag: 1.31.0-rc.0~43991 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=6634c4077e25ee1c56de0b15f4ab50a06b299c44;p=lhc%2Fweb%2Fwiklou.git Make getHistory() a bit more paging friendly --- 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; }