Problem/Motivation
When inline entity is edited, it will cause validation error upon saving entity: "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved."
This will happen only if 'changed' field of entity is newer then 'changed' of node. This situation can happen if same entity is referenced in two different nodes.
Steps to reproduce
- Create a node and create a new inline entity
- Create another node and reference the same entity
- Edit first node and try updating inline entity
- Validation error is shown
What's happening
This happens because upon form submission all node fields are copied to entity fields. Including 'changed' field. Now entity gets changed time which is older then stored changed time of entity. Therefore system thinks that there is a newer stored entity by someone else.
This happens during form validation:
- ContentEntityForm::validateForm
- EntityForm::buildEntity
- ContetnEntityForm::copyFormValuesToEntity
Proposed solution
No working solution yet.
Comment | File | Size | Author |
---|---|---|---|
#32 | if_inline_entity_is-2611956-32.patch | 6.94 KB | thenchev |
#32 | interdiff.txt | 1.69 KB | thenchev |
Comments
Comment #2
mikgreen CreditAttribution: mikgreen at Wunder commentedSomething like this works.
Comment #3
slashrsm CreditAttribution: slashrsm at Examiner.com commentedThis seems like duplicate of #2609020: Unable to reedit entity in a single request. Can you check?
Comment #5
mikgreen CreditAttribution: mikgreen at Wunder commentedNo, this happens with single entity. Unlike the other issue.
Also I tried latest dev with fix for other issue.
The problem is still there.
Comment #6
mikgreen CreditAttribution: mikgreen at Wunder commentedJust an update to match line numbers of current dev version.
Comment #7
slashrsm CreditAttribution: slashrsm at Examiner.com commentedThat other issue also happens with only one field. It was mentioned in a comment. Title was confusing. Fixed it.
Patch in that issue was committed. You can check if you still see this error with the latest HEAD.
Comment #8
axe312 CreditAttribution: axe312 at Wunder commentedThe error is not related to the other ticket, we have both issues in our project. First one is fixed, will now test this patch if it helps :)
Comment #9
slashrsm CreditAttribution: slashrsm at Examiner.com commentedNow I was able to reproduce. What about something like this? This patch removes all values that are not relevant for this specific IEF instead of just hardcoding one specific field name.
Comment #10
slashrsm CreditAttribution: slashrsm at Examiner.com commentedI think we will also need some test coverage for this.
Comment #13
slashrsm CreditAttribution: slashrsm at Examiner.com commentedThird argument to array_filter is PHP 5.6 feature. Question is if we want to require 5.6 or not.
Comment #15
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedHm... I can't reproduce this any more. I noticed this bug in slightly different situation than the one described in the summary:
1. Create content type A
2. Create two media bundles B and C
3. Configure nested complex IEF (A => B => C) - both references are multivalue ER fields
4. Create content of type A, add one media B and add few C on it.
5. Try to edit one of C media items
6. Boom!
However, I can't reproduce it any more. I also can't reproduce with steps from issue summary. Can anybody else reliably recreate this error in isolation?
Comment #16
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedAlso can't reproduce issue. Here is a test only patch with the steps from the summary.
Comment #17
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedComment #18
axe312 CreditAttribution: axe312 at Wunder commentedI was also no more able to reproduce since it is a lot of clicking, but I was still sure it may happen. The test of Denchev was missing the actual testing if the second edit attempt is working.
Here is a rewrite of the test, it is also now proving that the issue still exists. I also attached a working version of patch from #9, it is actually fixing the problem! :)
So let see what the test bot says!
Comment #19
axe312 CreditAttribution: axe312 at Wunder commentedComment #28
axe312 CreditAttribution: axe312 at Wunder commentedHere a new version which should pass in PHP 5.5
Comment #30
axe312 CreditAttribution: axe312 at Wunder commentedI am pretty sure it's all fine. The PostgreSQL test was failing for every patch here in the issue. Looks like an error in the test bot for me, does someone know more?
Comment #31
slashrsm CreditAttribution: slashrsm as a volunteer commentedYeah... Postgres test is failing quite often. I am pretty sure those fails are not related. I have just few cosmetic comments.
Do we really need to link the issue?
"Edit referenced node."?
"Edit referenced node."?
Comment #32
thenchev CreditAttribution: thenchev at MD Systems GmbH commented@axe312 tanks for fixing the test.
addressed #31
Comment #33
axe312 CreditAttribution: axe312 at Wunder commentedChanges of Denchev look good. Thx!
Comment #35
slashrsm CreditAttribution: slashrsm as a volunteer commentedI spoke with @bojanz and we agreed that we commit this and hopefully find a nicer solution later. It fixes a real problem which is enough for now.
Thank you everyone!