From 40b33eff69a8a44da0ab6962d50f2027bcfc33b6 Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 24 Sep 2006 01:51:09 +0200 Subject: fix recent changes cache ordering This patch fixes a bug in indexer.php which resulted in the order of the recent changes cache being reversed each time it was trimmed. It also adds sorting to both getRecents() and runTrimRecentChanges() as a defensive measure against the order of the file being corrupted. darcs-hash:20060923235109-9b6ab-0f4062c1b02449cce9382426174cd22d71387e5a.gz --- lib/exe/indexer.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib/exe/indexer.php') diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php index 649bb6f29..5cd030976 100644 --- a/lib/exe/indexer.php +++ b/lib/exe/indexer.php @@ -62,6 +62,7 @@ function runTrimRecentChanges() { if (@file_exists($conf['changelog']) && (filectime($conf['changelog'])+86400)= 0; $i--) { - $tmp = parseChangelogLine($lines[$i]); - if ($tmp===false) { continue; } - if ($tmp['date']>$trim_time || $kept<$conf['recent']) { - array_push($out_lines, implode("\t", $tmp)."\n"); - $kept++; - } else { - // no more lines worth keeping - break; - } + + for ($i=0; $i $conf['recent']) { + $out_lines = array_slice($out_lines,-$conf['recent']); // trim list to one page + } + + // save trimmed changelog io_saveFile($conf['changelog'].'_tmp', implode('', $out_lines)); @unlink($conf['changelog']); if (!rename($conf['changelog'].'_tmp', $conf['changelog'])) { -- cgit v1.2.3