From e45b34cdb82ad8fad44374c0d8f1df64952dc3a7 Mon Sep 17 00:00:00 2001 From: Ben Coburn <btcoburn@silicodon.net> Date: Mon, 11 Sep 2006 03:47:38 +0200 Subject: [PATCH] changelog redesign update - Improves handling of deleted revisions. - Import plugin disables after import. - Check act reports if plugin is still enabled after the import. - Import correctly handles summaries without the minor prefix. - Newlines and tabs are now striped out of type, sum, and extra in the changelog. darcs-hash:20060911014738-05dcb-2f6c9fdffb6346f7d3190610a72b290090b28097.gz --- inc/common.php | 17 +++++++++++++---- lib/plugins/importoldchangelog/action.php | 11 +++++++++-- lib/plugins/plugin/admin.php | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/inc/common.php b/inc/common.php index ca60b8edc..7c20c0b8f 100644 --- a/inc/common.php +++ b/inc/common.php @@ -737,14 +737,15 @@ function addLogEntry($date, $id, $type='E', $summary='', $extra=''){ $remote = $_SERVER['REMOTE_ADDR']; $user = $_SERVER['REMOTE_USER']; + $strip = array("\t", "\n"); $logline = array( 'date' => $date, 'ip' => $remote, - 'type' => $type, + 'type' => str_replace($strip, '', $type), 'id' => $id, 'user' => $user, - 'sum' => $summary, - 'extra' => $extra + 'sum' => str_replace($strip, '', $summary), + 'extra' => str_replace($strip, '', $extra) ); // update metadata @@ -1087,8 +1088,12 @@ function saveWikiText($id,$text,$summary,$minor=false){ $wasRemoved = empty($text); $wasCreated = !@file_exists($file); $wasReverted = ($REV==true); + $newRev = false; if ($wasRemoved){ + // pre-save deleted revision + @touch($file); + $newRev = saveOldRevision($id); // remove empty file @unlink($file); // remove old meta info... @@ -1107,6 +1112,7 @@ function saveWikiText($id,$text,$summary,$minor=false){ }else{ // save file (namespace dir is created in io_writeWikiPage) io_writeWikiPage($file, $text, $id); + $newRev = @filemtime($file); $del = false; } @@ -1121,7 +1127,7 @@ function saveWikiText($id,$text,$summary,$minor=false){ else if ($wasRemoved) { $type = 'D'; } else if ($minor && $conf['useacl'] && $_SERVER['REMOTE_USER']) { $type = 'e'; } //minor edits only for logged in users - addLogEntry(@filemtime($file), $id, $type, $summary, $extra); + addLogEntry($newRev, $id, $type, $summary, $extra); // send notify mails notify($id,'admin',$old,$summary,$minor); notify($id,'subscribers',$old,$summary,$minor); @@ -1366,6 +1372,9 @@ function check(){ msg('Importing old changelog now.', 0); } else if (@file_exists($conf['changelog'].'_import_ok')) { msg('Old changelog imported.', 1); + if (!plugin_isdisabled('importoldchangelog')) { + msg('Importoldchangelog plugin not disabled after import.', -1); + } } if(is_writable($conf['datadir'])){ diff --git a/lib/plugins/importoldchangelog/action.php b/lib/plugins/importoldchangelog/action.php index e927b3e26..37f3eb87d 100644 --- a/lib/plugins/importoldchangelog/action.php +++ b/lib/plugins/importoldchangelog/action.php @@ -38,8 +38,14 @@ class action_plugin_importoldchangelog extends DokuWiki_Action_Plugin { $oldline = @explode("\t", $line); if ($oldline!==false && count($oldline)>1) { // trim summary - $wasMinor = (substr($oldline[4], 0, 1)==='*'); - $sum = rtrim(substr($oldline[4], 1), "\n"); + $tmp = substr($oldline[4], 0, 1); + $wasMinor = ($tmp==='*'); + if ($tmp==='*' || $tmp===' ') { + $sum = rtrim(substr($oldline[4], 1), "\n"); + } else { + // no is_minor prefix in summary + $sum = rtrim($oldline[4], "\n"); + } // guess line type $type = 'E'; if ($wasMinor) { $type = 'e'; } @@ -171,6 +177,7 @@ function importoldchangelog_plugin_shutdown() { // import successful touch($path['import_ok']); @unlink($path['failed']); + plugin_disable('importoldchangelog'); // only needs to run once } } diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php index 643754771..0062d7370 100644 --- a/lib/plugins/plugin/admin.php +++ b/lib/plugins/plugin/admin.php @@ -23,7 +23,7 @@ require_once(DOKU_PLUGIN.'admin.php'); // plugins that are an integral part of dokuwiki, they shouldn't be disabled or deleted global $plugin_protected; - $plugin_protected = array('acl','plugin','config','info','usermanager', 'importoldchangelog'); + $plugin_protected = array('acl','plugin','config','info','usermanager'); /** * All DokuWiki plugins to extend the admin function -- GitLab