From 2167aeadf902c4c5d400383790307f98ff2853b1 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 1 Jan 2013 15:13:13 +0100 Subject: [PATCH] Only write page when it has been changed --- helper.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/helper.php b/helper.php index bf8de11..2991172 100644 --- a/helper.php +++ b/helper.php @@ -283,13 +283,17 @@ public function execute_rewrites($id, $text = null) { if($meta && isset($meta['moves'])) { if(is_null($text)) $text = rawWiki($id); + $old_text = $text; $text = $this->rewrite_content($text, $id, $meta['moves']); + $changed = ($old_text != $text); $file = wikiFN($id, '', false); - if(is_writable($file)) { - // Wait a seconf if page has just been saved - $oldRev = getRevisions($id, -1, 1, 1024); // from changelog - if ($oldRev == time()) sleep(1); - saveWikiText($id, $text, $this->getLang('pm_linkchange')); + if(is_writable($file) || !$changed) { + if ($changed) { + // Wait a second if page has just been saved + $oldRev = getRevisions($id, -1, 1, 1024); // from changelog + if ($oldRev == time()) sleep(1); + saveWikiText($id, $text, $this->getLang('pm_linkchange')); + } unset($meta['moves']); p_set_metadata($id, array('plugin_pagemove' => $meta), false, true); } else { // FIXME: print error here or fail silently?