Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTM] Warn if another user has edited a record #809

Merged
merged 4 commits into from
May 5, 2017
Merged

[RTM] Warn if another user has edited a record #809

merged 4 commits into from
May 5, 2017

Conversation

leofeyer
Copy link
Member

@leofeyer leofeyer commented May 5, 2017

This PR implements contao/core#8412.

@leofeyer leofeyer added this to the 4.4.0 milestone May 5, 2017
@leofeyer leofeyer self-assigned this May 5, 2017
@leofeyer leofeyer requested review from ausi, Toflar and aschempp May 5, 2017 10:26
@leofeyer leofeyer changed the title [RTM] Warn if another user has edited a record when saving it [RTM] Warn if another user has edited a record May 5, 2017
@jankout
Copy link

jankout commented May 5, 2017

Thank you very much.

if ($intLatestVersion !== null && isset($arrRecords[$this->strTable][$this->intId]) && $intLatestVersion > ($arrRecords[$this->strTable][$this->intId] + 1))
{
\Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['versionWarning'], ($intLatestVersion - 1), $arrRecords[$this->strTable][$this->intId]));
$this->reload();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I read the code, the process is as follows: If somebody saved a new version until I hit the save button, it will reload and show the message but it will not store my data to the database. Is that correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think saving is already done at this point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. So it does actually not prevent you from overriding the values but it just tells you that you did override it. That's fine for me I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overridden values are still available via the versions dropdown, so it should be fine I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's wrong (of course). It just prevents any redirects so the user stays on the same page and actually sees the error message.

@ausi
Copy link
Member

ausi commented May 5, 2017

This implementation relies on the session, so if the same user (or another users logged in with the same account) edits the same element, the warning is not shown. Wouldn’t it be better to use a hidden field in the edit form instead of the edit_records array in the session?

@Toflar
Copy link
Member

Toflar commented May 5, 2017

This implementation relies on the session, so if the same user (or another users logged in with the same account) edits the same element, the warning is not shown. Wouldn’t it be better to use a hidden field in the edit form instead of the edit_records array in the session?

I think that would be really cool. It also reduces session noise.

@leofeyer
Copy link
Member Author

leofeyer commented May 5, 2017

I have reworked the implementation to use a hidden field instead of the session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants