In #2631590: After previewing an entity with nested paragraphs, EntityChangedConstraintValidator sometimes leaves a node entity un-saveable we discussed various problems encountered while using nested paragraphs that were difficult to find steps to reproduce. It was hoped that #2676098: Do not save in widget would fix these, but it appears it hasn't solved it completely. I have however managed to find steps to reproduce ...
On simplytest.me with paragraphs_demo, paragraphs 8.x-1.x-dev (commit 627d5d8 I think) and ERR 8.x-1.0-rc6:
- Create a new paragraph type "Twin nested paragraphs".
- Add the existing "field_paragraphs_demo" field to it with the label "paras1".
- Add a new paragraphs field to it with the label "paras2".
- On manage form display, make sure the widget is set to Paragraphs for paras1.
- Create a piece of content of type "paragraphed article".
- In the paragraphs field of that content, add a paragraph of type "Twin nested".
- Then add another paragraph below it of type "Nested".
- Save the node.
- Edit the node.
- Inside the "Nested paragraph" add another paragraph of type "Twin nested".
- In the "paras1" field of this new paragraph, add a text paragraph and enter some text.
- Save the node.
- Enjoy the WSOD.
I have not managed to get the same problem when using the demo nested paragraphs type that has only one paragraphs field on the paragraph type, so it may be that the problem is specific to having multiple paragraphs fields on one paragraph type.
I'm suggesting critical priority because of the potential loss of unsaved data.
To reproduce without the demo paragraphs module, do the following. (Used core 8.0.6, paragraphs-8.x-1.0-rc4+25-dev, and entity_reference_revisions-8.x-1.0-rc6+2-dev)
- Create Paragraph types:
- Text Paragraph: one "Text (Plain)" field
- Nested Single: one Paragraph field named field_paragraph_1
- Nested Double: two Paragraph fields
- Use existing field_paragraph_1. Update form display to use Paragraph widget.
- Create field_paragraph_2
- Create content type: Paragraphed Article
- Remove the Body field
- Add field: Paragraph
- Create a new Paragraphed Article node
- Add a Nested Single paragraph to the node
- In the Nested Single paragraph:
- Add a Nested Double paragraph
- In field_paragraph_1 of this paragraph, add a Text paragraph and enter some text.
- Attempt to save the node
- See WSOD
Comments
Comment #2
jonathanshawComment #3
killua99 commentedThis could be a major problem for editors distros.
Comment #4
miro_dietikerAdded this issue to the roadmap to stable.
Comment #5
berdir> - On manage form display, set the widget to autocomplete for paras1.
Autocomplete = reference an existing paragraph?
That is no longer supported. Paragraphs are composite of their parent now, they can only be used once.
Comment #6
berdirAlso, please either configure PHP to display errors or check your apache logs. Saying that you have a WSOD is like saying you had a bluescreen windows, it could be anything.
Comment #7
jonathanshawThanks for the tip. admin/reports/dblog gives me:
"LogicException: Form errors cannot be set after form validation has finished. in Drupal\Core\Form\FormState->setErrorByName() (line 1120 of /home/r0669/www/core/lib/Drupal/Core/Form/FormState.php)."
Comment #8
berdirCan you set display errors in drupal to verbose and then post the full backtrace? Then we can see how this is called. I believe I've seen this somewhere else too.
Comment #9
jonathanshawThis?
LogicException: Form errors cannot be set after form validation has finished. in Drupal\Core\Form\FormState->setErrorByName() (line 1120 of core/lib/Drupal/Core/Form/FormState.php).
Drupal\Core\Form\FormState->setError(Array, Object) (Line: 446)
Drupal\Core\Field\WidgetBase->flagErrors(Object, Object, Array, Object) (Line: 260)
Drupal\Core\Entity\Entity\EntityFormDisplay->flagWidgetsErrorsFromViolations(Object, Array, Object) (Line: 247)
Drupal\Core\Entity\Entity\EntityFormDisplay->validateFormValues(Object, Array, Object) (Line: 1115)
Drupal\paragraphs\Plugin\Field\FieldWidget\InlineParagraphsWidget->massageFormValues(Array, Array, Object) (Line: 375)
Drupal\Core\Field\WidgetBase->extractFormValues(Object, Array, Object) (Line: 227)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object, Array, Object) (Line: 228)
Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 296)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 79)
Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object) (Line: 281)
Drupal\Core\Entity\EntityForm->submitForm(Array, Object) (Line: 69)
Drupal\Core\Entity\ContentEntityForm->submitForm(Array, Object) (Line: 322)
Drupal\node\NodeForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 116)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 56)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 588)
Drupal\Core\Form\FormBuilder->processForm('node_paragraphed_content_demo_edit_form', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 79)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 128)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 577)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 129)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 102)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 62)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 103)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 82)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 55)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 637)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #10
johnchqueNot sure if this is a bug report or feature request since
is no longer supported.
Comment #11
jonathanshawSorry. that was a mistake. I meant "make sure the widget is set to Paragraphs for paras1".
Comment #12
jonathanshawComment #13
jonathanshawIn #2697065: Nested Paragaraph with Required field results in Fatal Error there was a suggestion that validations were being executed prematurely; perhaps this is related.
Comment #14
johnchqueTested manually, the problem is present just when you use the existing 'field_paragraphs_demo'. I tried creating a new paragraph field instead and works fine. (So having two new paragraphs field in the twins paragraph type)
@jonathanjfshaw can you test if it works doing it in that way? please note that the demo module is just for example purposes.
Comment #15
berdirStill, an error like this isn't supposed to happen.
Can you debug what error is being thrown exactly? That's what we need to fix.
It's also strange that the error is only thrown the second time massageFormValues() is called. Maybe we need to find a way to do validate earlier.
Comment #16
jonathanshawI definitely got this also when not using the demo module, it's not specific to that.
Comment #17
jonathanshawI retested from scratch and can confirm, this is not limited to the demo module.
Create a content type with a paras field, create a para type with a text field, create a para type with a paras field, then follow the steps from the IS.
Comment #18
paulmckibbenI am also able to reproduce this error without the demo module. I have updated the summary to describe the steps to reproduce without the demo module. I will continue to look for a fix.
Comment #19
paulmckibbenAssigning to myself. If somebody is already looking into this, please let me know. Thanks!
Comment #20
miro_dietikerYeah i was able to reproduce.
I'm reducing the description to the relevant steps.
The problem is, during the submit handler, a validation is executed again and tries to setError().
The problem is that InlineParagraphsWidget::massageFormValues() does uncommon things, including:
And that's terribly wrong during a submit.
Comment #21
miro_dietikerComment #22
berdir@paulmckibben:
I've been looking into this with @yongt9412 as well, not sure if he already has some code, he can update the issue tomorrow.
There are actually two problems here. One is that we are validating during submit, which, as Miro mentioned is wrong. Fixing that is easy, we just have to remove the calls. We should however make sure we have some tests that validation still happens at some point. We need a field type with some special validation that is not covered by form validation already for that. I suggest we repurpose this issue to something like "Do not validate during form submission".
It's the second problem that I'm more worried about. Yes, validating during submit is bad, but since we also validate on validate, we shouldn't actually get any validation errors? Based on what we've seen, somehow the valid reference validation fails because the target paragraph type is wrong. It looked like it would be using the wrong field to validate it. We should open a separate issue to investigate that. *Maybe* it's caused by the duplicate validation, but I'm not sure yet. For example, once this initial bug is fixed, we need to re-save the same node to make sure that validation on validate then also doesn't fail.
Comment #23
johnchqueThanks @paulmckibben for adding the steps to reproduce. As @Berdir wrote we have been looking into this, I tried debugging and it seems it is caused by the validation during submit, testing a bit, tried setting the field as required(which is not related with the issue) and deleting the validation during submit in the node and I got a message: 'The entity Paragraph:'' cannot be referenced' instead of the WSOD. As @Berdir wrote above it seems like it would be using the wrong field to validate it.
IMHO we should remove the validation during submit in this issue and continue in a new one with the investigation.
Comment #24
miro_dietikerRetitling. Summary might need update too.
Comment #25
paulmckibben@yongt9412 or @berdir, if either of you have ideas to fix this in short order, please go for it. I will continue to look at it as well, but changing back to unassigned in case others can get to it more quickly.
Comment #26
4aficiona2 commentedWhile adding content in a multilang Paragraph setup I ran into the following issue when I tried to resave / translate entities.
"The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved."
Its weird because it appears only on certain nodes and I can not see a pattern.
I found multiple issues like #2631590, #2597201, the one above and quite some more which do also mention this but are marked as solved.
So I am not sure if this might be related to this issue because it is an newer one / ongoing? But I can not save certain nodes, they are kind of locked and I get always the error when I try to save / resave a node.
I was using Drupal 8.1, paragraphs 8.x-1.0-rc4, Entity Reference Revisions 8.x-1.0-rc6 ... when the error showed up installed paragraphs 8.x-1.x-dev (22nd of April) but the error is the same. Did a miss a specific patch or should this be covered by the latest dev release?
It weird because it appears only on certain nodes. Can not see a pattern.
Comment #27
johnchque@4aficiona2 can you also test updating entity_reference_revisions module? there have been some changes that are related with paragraphs. Can you also try to find the steps to reproduce the problem?
Also, added related issue. We are working with validation there too.
Comment #28
4aficiona2 commented@yongt9412 thx, I will update entity_reference_revisions to dev version and will keep the thread updated. But the issue which you mentioned #2556539 seems to me unrelated because my paragraphs and paragraphs fields are all optional.
Comment #29
johnchqueThank you @4aficiona2. Please take note if you update from a previous version run also the db updates.
I am adding the issue since the validation is also related with required fields and will change in that issue.
Comment #30
4aficiona2 commented@yongt9412 unfortunately this did not the trick. Updated entity_reference_revisions to the latest dev version 8.x-1.0-rc6+5-dev and running D8.1, Paragraphs 8.x-1.0-rc4+28-dev and I still get the message "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved." when I try to save certain nodes.
Any other way to bypass those checks? Or did I miss a patch? So far I have not applied any patches just using the dev versions of Paragraphs and entity_reference_revisions.
Comment #31
johnchque@4aficiona2 thank you. Can you try writing the specific steps for reproducing the issue so we can write tests for it.
Comment #32
4aficiona2 commented@yongt9412 I also ran
drush updatedbbut there was no db update available. I used entity_reference_revisions-8.x-1.0-rc6 before and upgraded to entity_reference_revisions-8.x-1.x-dev. There seems to be no DB updates.I have one DB update pending (from D8.0.6 to D8.1) which can not be run but is an other issue #2407853.
Comment #33
4aficiona2 commentedI assume the fixes / updates from the dev versions of paragraphs and entity_reference_revisions module work on existing content (already created content which yield the following error messages) and not only on newly created content.
Here are all the three error messages (english, german, french) form my setup if somebody is searching the error messages in an other language to find this issue.
"The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved."
"Der Inhalt wurde entweder von einem anderen Benutzer bearbeitet oder Sie haben schon Änderungen gespeichert. Deshalb können diese Änderungen nicht gespeichert werden."
"Le contenu a été modifié par un autre utilisateur ou vous avez déjà soumis vos modifications. Vos dernières modifications ne peuvent donc pas être enregistrées."
Or do they only work for created content added after updating the modules ?
Comment #34
johnchqueYes, it should also work with existing content, did you run db updates of paragraphs too? Can you write a description of the following:
- Paragraphs types that you have where you get the message.
- If referencing fields are entity reference revisions (We don't support entity_reference field to make the reference to the paragraphs anymore).
- Please note that reusing paragraphs is not supported.
That would help us to reproduce the problem and write tests.
Comment #35
4aficiona2 commented@yongt9412 yes, when I updated paragraphs to the dev version I ran db updates too.
I will try to explain what is going on. I have a multilang page for a foundation based in Switzerland. The contents are available in three language (german, french & english).
So I created all pages / nodes first in german, the default language with all their paragraphs and then started to translate and while adding the translations in the last couple of days, the above mentioned error message showed up.
I will provide 2 screenshots. The first screenshot shows all three translated nodes. The only one of those three nodes which I can save is the french one. When I try to save the german or the english one I get the error message which you can see in the 2nd screenshot.
There I have 4 paragraphs:
entity reference revisions, Entity reference), in this case to a a teaserbox, and the teaserbox itself contains a viewfield.But there are many more paragraphs available which are not used on this particular page.
Comment #36
johnchque@4aficiona2 thanks for the feedback. Since the issue you describe needs its own fix I opened an issue for solving it. #2715855: Remove changed field to fix changed validation when trying to update old revisions
Comment #37
4aficiona2 commented@yongt9412 I double checked my paragraph which references the teaserbox of the above example. It uses entity reference, not entity reference revisions like I mentioned earlier. I am not sure if it makes a difference because I do not fully understand what you meant in the comment #34 above?
I added a screenshot of the field definition of my paragraph. Besides text, quote, title paragraphs I defined 9 different paragraph types which can reference nodes. Some enable full width content with different viewmodes Teaser / Teaser-Detail and allow only one reference, others display the referenced nodes in 1/2/3/4/6 column layout.
I built 2 sites with this paragraph setup where editors have created / written around 500 nodes already and are now starting to translate those nodes ... and the errors like mentioned above (#33) are showing up.
I really hope I do missunderstand you because what I understand is the I would have to change all my paragraphs to use a entity reference revisions field to reference nodes instead of entity references which I use so far (see screenshot) and therefore all already referenced nodes need to be referenced again by a entity reference revisions field?
Hopefully I am missunderstanding something and this is a bug and not possible by design?
Comment #38
johnchque@4aficiona2 thanks for replying, entity_reference fields are not supported as reference fields to paragraphs. What you are describing is a paragraph with an entity_reference field, that IS supported and it is not related with the "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved." message issue. In other words, you cannot have nodes with entity_reference fields for referencing Paragraphs but you can use entity_reference fields in a paragraph for referencing nodes/users etc.
Comment #39
4aficiona2 commented@yongt9412 thanks for your fast reply! So if I understand you right, my usecase is still valid and supported but you say it is not related to the error "The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved." which does appear on my pages like I described in #26. And you mean it has nothing to do with this (2706603) issue and is an own one which you opened / created?
Comment #40
johnchque@4aficiona2 yes, it is still valid. :)
What I mean is that the message is related with #2715855: Remove changed field to fix changed validation when trying to update old revisions
Comment #41
4aficiona2 commented@yongt9412 yes :-) really really glad to hear that! Otherwise "months" of work would have vanished into "thin air". So how can I contribute or support to get Remove changed field done?
Comment #42
johnchqueComment #43
johnchqueI knew it was something strange there! Able to reproduce in tests, this should fix the problem.
Comment #48
miro_dietikerReads.So.Much.Nice. :-)
Awesome work. Committed.