-
Notifications
You must be signed in to change notification settings - Fork 641
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
Incorrect behaviour when duplicating element #4758
Comments
I just double checked and everything is working correctly. Here’s the expected order of operations:
If you’re seeing a second event where |
My mistake, the second time around |
It’s best to send user notifications in a separate request via a background job added to the queue, so if you go that route, by the time the job is executed, the title will already be updated to the new title. |
Ok, thanks for the pointer. I'm probably not seeing the bigger picture here, but the order of operations appears to be a bit convoluted and contains a permission check (point 2 below) which doesn't necessarily seem appropriate when a user has clicked on "Save as a new entry".
A more suitable (and simpler) order of operations might be:
If this makes sense then I'd be happy to submit a pull request, otherwise I'll just go with the queue job :) |
Steps 1 and 2 on your first list are backwards – all permission enforcement is done before the entry is duplicated: cms/src/controllers/EntriesController.php Lines 328 to 334 in 620fa9e
But I see your point – there’s no need to enforce the Your suggestion to simply drop the This is also the reason why we start by duplicating the entry as-is, before applying the posted content to it and re-saving it – if we were to go straight to applying the posted content and then re-saving, it would make it much harder to determine which field values should stay identical to how they were on the original entry for other sites. By fully duplicating the original entry as-is first, we know that the field translation settings will be applied to the incoming content exactly the same way it would have been for the original entry, had they clicked “Save” instead of “Save as a new entry”. |
I see, thanks for the thorough explanation Brandon, I had a feeling that I wasn't seeing the big picture here!! |
Description
When clicking on
Save as a new entry
,Elements::EVENT_AFTER_SAVE_ELEMENT
is called on the old element withisNew
incorrectly set totrue
.Steps to reproduce
Save and continue editing
an entry with the titleEntry 1
.Entry 2
and clickSave as a new entry
.Elements::EVENT_AFTER_SAVE_ELEMENT
event is triggered first forEntry 1
withisNew
set totrue
, then again forEntry 2
withisNew
set totrue
.Additional info
The text was updated successfully, but these errors were encountered: