From 8788b89ce5866ebbc150f34a619e82723e0318ae Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 4 Oct 2015 08:59:35 +0100 Subject: [PATCH] Resave the pagedata if it has been changed by the preprocessors --- modules/page-edit.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/page-edit.php b/modules/page-edit.php index 269b2de..ad2af52 100644 --- a/modules/page-edit.php +++ b/modules/page-edit.php @@ -139,6 +139,10 @@ register_module([ else $pageindex->$page->lasteditor = utf8_encode("anonymous"); + // A hack to resave the pagedata if the preprocessors have + // changed it. We need this because the preprocessors *must* + // run _after_ the pageindex has been updated. + $pagedata_orig = $pagedata; // Execute all the preprocessors foreach($save_preprocessors as $func) @@ -146,6 +150,9 @@ register_module([ $func($pageindex->$page, $pagedata); } + if($pagedata !== $pagedata_orig) + file_put_contents("$env->page.md", $pagedata); + file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT));