-
-
Notifications
You must be signed in to change notification settings - Fork 213
Feature: to lock a content element, module, article, page etc. when somebody else is editing it at the same time #8412
Comments
As discussed at the developer's meeting in July 2016, access tracking should be bound to version numbers, which simplifies recognizing "dead lock". Also, if a new version is created while someone is editing an element, there should be a flash message telling them when saving it. |
Great. Thank you very much. |
Here's how I would implement it: interface LockService
{
/**
* Adds a new lock entry.
*
* @param string $table The table name
* @param int $id The record ID
* @param int $sessionId The ID of the user session
* @param int|null $version An optional version number if versioning is supported
*/
public function lock($table, $id, $sessionId, $version = null);
/**
* Checks if an entry is locked.
*
* - Is the element still at the locked version?
* - Is there still a session matching the session ID?
*
* @param string $table The table name
* @param int $id The record ID
*
* @return bool
*/
public function isLocked($table, $id);
/**
* Removes a lock entry.
*
* @param string $table The table name
* @param int $id The record ID
* @param int $sessionId The ID of the user session
*
* @return int|null The initial version number or null if versioning is not supported
*/
public function unlock($table, $id, $sessionId);
} Then we could use it like this: $lockService = $container->get('contao.lock_service');
if ($lockService->isLocked('tl_content', 22)) {
// Show a "the element is currently edited by user X" screen
// Proceed or go back?
}
$lockService->lock('tl_content', 22, 2, 8);
// Show the edit screen
if ($canSave) {
// save
$initialVersion = $lockService->unlock('tl_content', 22, 2);
if ($newVersion != $initialVersion + 1) {
// Show a "user X has created another version while you were editing" screen
}
} It could work something like this:
@contao/developers Does this make sense? |
Great. For me it sounds good. Maybe it would be useful to see in the backend at the start who else is login-in. |
I wonder if we need to use the database for this or we should use a cache service?
Also, we need to implement expiration, maybe checking the user's session.
|
I think there is a lot to consider. It should not require aditional user interaction to proceed. |
It is already part of the interface. Read the phpDoc of the |
It definitely should! There must be an option to know about the lock status before the edit form is loaded. Otherwise there would be a lock entry and no way for us to prevent a deadlock if the user hits the "go back" button. |
So you would impose a lock when the edit form is loaded? But the user could still go back then without saving. |
That was not the original request. |
I would like to have a feature to lock a content element, module, article, page etc. when somebody else is editing it at the same time. Admin could set whether and what should be locked when the described situation comes.
For example in the Typo3 works like this: when admin wants to edit something what somebody else is editing at the same time, it appears a notice (pop up) that somebody is editing and if you want to go on, you take the risk to overwrite it.
Always when two or more persons are editing something in the backend there should be a lock symbol next to the editing content.
The text was updated successfully, but these errors were encountered: