Skip to content
Snippets Groups Projects
Commit 84de34fb authored by Ben Coburn's avatar Ben Coburn
Browse files

make importoldchangelog plugin more user friendly

The plugin places all the changelog lines into the recent changes cache.
Truncating this cache is left to the code that normally trims the recent
changes cache. $conf['recent_days'] defines the maximum age of changes to
be considered "recent". If no changes are "recent" the changelog cache
trimmer will leave some stale changes in the cache to avoid emptying it
completely.

darcs-hash:20061030023710-05dcb-6a870d8597aeb22769de00dfb977d394881b9de8.gz
parent d5e16410
No related branches found
No related tags found
Loading
......@@ -11,10 +11,10 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
return array(
'author' => 'Ben Coburn',
'email' => 'btcoburn@silicodon.net',
'date' => '2006-08-30',
'date' => '2006-10-29',
'name' => 'Import Old Changelog',
'desc' => 'Imports and converts the single file changelog '.
'from the 2006-03-09b release to the new format. '.
'from the 2006-03-09 release to the new format. '.
'Also reconstructs missing changelog data from '.
'old revisions kept in the attic.',
'url' => 'http://wiki.splitbrain.org/wiki:changelog'
......@@ -53,7 +53,7 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
if ($sum===$lang['deleted']) { $type = 'D'; }
// build new log line
$tmp = array();
$tmp['date'] = $oldline[0];
$tmp['date'] = (int)$oldline[0];
$tmp['ip'] = $oldline[1];
$tmp['type'] = $type;
$tmp['id'] = $oldline[2];
......@@ -86,7 +86,7 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
if (!isset($logs[$id])) { $logs[$id] = array(); }
if (!isset($logs[$id][$date])) {
$tmp = array();
$tmp['date'] = $date;
$tmp['date'] = (int)$date;
$tmp['ip'] = '127.0.0.1'; // original ip lost
$tmp['type'] = 'E';
$tmp['id'] = $id;
......@@ -107,17 +107,13 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
}
function savePerPageChanges($id, &$changes, &$recent, $trim_time) {
$out_lines = array();
function savePerPageChanges($id, &$changes, &$recent) {
ksort($changes); // ensure correct order of changes from attic
foreach ($changes as $tmp) {
$line = implode("\t", $tmp)."\n";
array_push($out_lines, $line);
if ($tmp['date']>$trim_time) {
$recent[$tmp['date']] = $line;
}
foreach ($changes as $date => $tmp) {
$changes[$date] = implode("\t", $tmp)."\n";
$recent[$date] = &$changes[$date];
}
io_saveFile(metaFN($id, '.changes'), implode('', $out_lines));
io_saveFile(metaFN($id, '.changes'), implode('', $changes));
}
function resetTimer() {
......@@ -147,9 +143,8 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin {
// save per-page changelogs
$this->resetTimer();
$recent = array();
$trim_time = time() - $conf['recent_days']*86400;
foreach ($log as $id => $page) {
$this->savePerPageChanges($id, $page, $recent, $trim_time);
$this->savePerPageChanges($id, $page, $recent);
}
// save recent changes cache
$this->resetTimer();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment