From 27fbc76105241574d75bf28e31676c4801a55ea9 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 24 Sep 2006 18:21:05 +0200 Subject: update to previous changes cache patch - fix potential array key collisions - restore ability to keep a minimum number ($conf['recent']) of recent changes irregardless of date of change darcs-hash:20060924162105-9b6ab-06350f04f9d9ac4c362f13787b682ef70887a1fc.gz --- lib/exe/indexer.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib/exe/indexer.php') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index cfbd4ba4b..224c54311 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -62,7 +62,6 @@ function runTrimRecentChanges() { if (@file_exists($conf['changelog']) && (filectime($conf['changelog'])+86400) $conf['recent']) { - $out_lines = array_slice($out_lines,-$conf['recent']); // trim list to one page + // sort the final result, it shouldn't be necessary, + // however the extra robustness in making the changelog cache self-correcting is worth it + ksort($out_lines); + $extra = $conf['recent'] - count($out_lines); // do we need extra lines do bring us up to minimum + if ($extra > 0) { + ksort($old_lines); + $out_lines = array_merge(array_slice($old_lines,-$extra),$out_lines); } // save trimmed changelog -- cgit v1.2.3