[dokuwiki] Re: Recent changes

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sun, 24 Sep 2006 17:41:07 +0100

Ben Coburn wrote:


Chris,
I'm confused, or maybe you misunderstood how I intended the changelog trimmer to work....


The original intent was for the recent changes to be trimmed to everything newer than N days OR X lines (which ever was larger). Where N=$conf['recent_days'] and X=$conf['recent']. In a fast moving wiki N may equal one week or even one day, but a slower moving wiki could use N of one month or more. In a slow moving wiki (if no one edited anything over the holidays) it would be better to have the most recent stale changes still visible, instead of no changes. This is why I added the clause to keep at least X changes when trimming the recent changes log.

Hi Ben,

Ok, I missed that, you're new comment does it make it much clearer.  :-)

You're updated patch will work fine with a correctly ordered changelog, but it will have problems if the ordering is messed up. Given the much reduced size of the changelog cache, carrying out a key sort costs very little time and I think the extra robustness is worth it. e.g. on my server, with 53 out of order entries in the change log, its takes 0.5ms to reorder them (indexer.php takes 85ms to run from start to finish).

Also, anyone who has been using a darcs version of snapshot from the last few weeks will have an incorrectly ordered recent changes cache which needs fixing ;-)

On reflection my method of simply creating keys using the change time is flawed as it is possible for two changes to be made in the same second. Below is my patch to update last night's changes:

Cheers,

Chris


hunk ./lib/exe/indexer.php 65
-
hunk ./lib/exe/indexer.php 73
- io_saveFile($conf['changelog'].'_tmp', ''); // presave tmp as 2nd lock
+ io_saveFile($conf['changelog'].'_tmp', ''); // presave tmp as 2nd lock
hunk ./lib/exe/indexer.php 79
- if ($log === false || $log['date'] < $trim_time) continue; // discard old lines
- $out_lines[$log['date']] = $lines[$i]; // preserve the rest
+ if ($log === false) continue; // discard junk
+ if ($log['date'] < $trim_time) {
+ $old_lines[$log['date'].".$i"] = $lines[$i]; // keep old lines for now (append .$i to prevent key collisions)
+ } else {
+ $out_lines[$log['date'].".$i"] = $lines[$i]; // definitely keep these lines
+ }
hunk ./lib/exe/indexer.php 87
- ksort($out_lines); // sort lines, just in case!
- if (count($out_lines) > $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);




--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: