diff --git a/action.php b/action.php index fdea668..dcb4200 100644 --- a/action.php +++ b/action.php @@ -51,10 +51,15 @@ function handle_read(Doku_Event $event, $param) { if (isset($stack[$id])) return; - // Don't change the page when the user is currently changing the page content or the page is locked by another user - // FIXME: this doesn't work, most probably because $ACT is an array or not yet set - if ((isset($ACT) && (in_array($ACT, array('save', 'preview', 'recover', 'revert')))) - || checklock($id) !== false) return; + // Don't change the page when the user is currently changing the page content or the page is locked + $forbidden_actions = array('save', 'preview', 'recover', 'revert'); + if ((isset($ACT) && ( + in_array($ACT, $forbidden_actions) || (is_array($ACT) && in_array(key($ACT), $forbidden_actions) + ))) + // checklock checks if the page lock hasn't expired and the page hasn't been locked by another user + // the file exists check checks if the page is reported unlocked if a lock exists which means that + // the page is locked by the current user + || checklock($id) !== false || @file_exists(wikiLockFN($id))) return; $helper = $this->loadHelper('pagemove', true); if(!is_null($helper)) { diff --git a/helper.php b/helper.php index 083fe98..5ddda97 100644 --- a/helper.php +++ b/helper.php @@ -344,7 +344,10 @@ public function move_page(&$opts, $checkonly = false) { } // Check file is not locked - if (checklock($ID) !== false) { + // checklock checks if the page lock hasn't expired and the page hasn't been locked by another user + // the file exists check checks if the page is reported unlocked if a lock exists which means that + // the page is locked by the current user + if (checklock($ID) !== false || @file_exists(wikiLockFN($ID))) { msg( sprintf($this->getLang('pm_filelocked'), hsc($ID)), -1); return false; }