-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
CRM-20892: Prevent cross-editing of mailings between multiple browser/tab instances #10864
Conversation
Can one of the admins verify this patch? |
Jenkins ok to test |
Thanks for your work on this! Looks good in theory. Just a few thoughts. Why not call it modified_date to make it consistent with the same field on the contact entity, and store it as the same data type: civicrm-core/xml/schema/Contact/Contact.xml Lines 860 to 868 in 23e6588
The lock on the contact entity works essentially in the same way: https://github.com/civicrm/civicrm-core/blob/648631cd94799e87fe2347487d465b1a7256aa57/CRM/Contact/Form/Edit/Lock.php I think it would be better to keep things consistent. Then - we can update the comments/documentation rather than referring to it as a 'modified ID' it is simply the last modified date. For completeness it would also be good to add a test for this. |
@totten you need to look at this one. I totally agree this is a serious issue and I know of another screen (in that case quickform) where it happens so we need to have some guidelines about best approach/s for this |
@awzilkie good call in using the modification-time as an optimistic lock mechanism (oplock). I agree with @JKingsnorth that it should do a column
There is an important difference between contact UI and mailing UI -- the mailing UI goes through APIv3 (no QuickForm). The contact examples don't show how to do oplocking with APIv3 -- and existing integrations don't expect APIv3 to enforce oplocking. Here's a design you could try -- update the APIv3 contract so support an // Basic API request which ignores oplocking. Default for backward compatibility.
$response = civicrm_api3('Mailing', 'create', array(
'id' => 123,
'modified_date' => 'willbeignored',
// and other changes...
));
// API request which participates in oplocking.
$response = civicrm_api3('Mailing', 'create', array(
'options' => array('oplock' => 1),
'id' => 123,
'modified_date' => 'the-last-seen-timestamp',
// and other changes...
)); For implementation, here are some things you could try:
|
Thanks for the groundwork, I think this can be closed in favour of #10965 ? |
Closing in favour of 10965 |
Overview
CRM-20892: Prevent cross-editing of mailings between multiple browser/tab instances
Before
When the same mailing is open in two different tabs, changes from one can overwrite changes from the other even if the mailing has been submitted!
Steps to recreate:
This can happen with multiple tabs on the same PC, or different users on different PCs (if two people end up working on the same mailing).
After
Add a new column
last_modified
to the civicrm_mailing table in the DB to keep track of the last browser instance to change the DB. This id will be based on the number of seconds since the epoch at the time the mailing was created or continued to ensure that it is always unique.Each browser instance keeps its own unique last modified ID as described above. When a change is made in a browser instance, before it is saved to the DB check if the browser's ID matches that stored in the database for that mailing. If they do not match, bock the change and throw an appropriate error message.
Technical Details
Add
last_modified
column to thecivicrm_mailing
table in mysql incremental upgrade file for version 4.7.25Comments
None