Skip to content

Commit

Permalink
Only write page when it has been changed
Browse files Browse the repository at this point in the history
  • Loading branch information
michitux committed Jan 1, 2013
1 parent 259aea9 commit 2167aea
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 2167aea

Please sign in to comment.