Skip to content

Commit

Permalink
Fix the prevention of automatic edits for pages that are currently lo…
Browse files Browse the repository at this point in the history
…cked or edited

This makes the lock check more strict by reporting pages as locked that
are locked by the current user in order to prevent accidently moving or
modifying pages that are currently edited.
  • Loading branch information
michitux committed Oct 29, 2013
1 parent 4f5f2d3 commit ec7eb75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 4 additions & 1 deletion helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ec7eb75

Please sign in to comment.