Needs work
Project:
Paragraphs
Version:
8.x-1.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
18 Feb 2017 at 08:22 UTC
Updated:
13 May 2021 at 13:47 UTC
Jump to comment: Most recent, Most recent file
To reproduce:
* Install demo
* Limit the paragraph field for both the node field and the nested field to the nested field type. => Boom.
We need to add a static that counts the amount of nested elements and somehow limit it. Not sure based on what exactly we want to limit, like number of same paragraph types and then stop adding a default? Or total amount and a bit higher limit?
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | recursion_loop_if-2853759-20.patch | 11.22 KB | anand.toshniwal93 |
| #15 | recursion_loop_if-2853759-15.patch | 11.07 KB | toncic |
| #12 | interdiff-2853759-10-12.txt | 3.66 KB | toncic |
| #12 | recursion_loop_if-2853759-12.patch | 6.33 KB | toncic |
| #10 | interdiff-2853759-5-10.txt | 2.39 KB | toncic |
Comments
Comment #2
johnchqueDoes this really happen? I cannot reproduce, where does it "boom" exactly? when saving or when editing/viewing a node?
Comment #3
berdirWhen you edit.
Because we will add a default paragraph in your field, that paragraph has a paragraph field, which will add the same default paragraph, which also has a paragraph field (as it is the same type) and it will add another one and so on..
Comment #4
miro_dietikerWe could also simply disallow adding the own type as child again?
Comment #5
toncic commentedI tried @miro_dietiker proposal and seems like works, but test failing.
Comment #6
toncic commentedComment #7
toncic commentedJust to check what tests will say.
Comment #9
primsi commentedMaybe I got this wrong, but isn't this only a problem with nested ones? So shouldn't we check if current and parent are nested?
Comment #10
toncic commentedI forgot to fix this for classic paragraphs.This is working pretty fine for me, hope it is a good approach.
Comment #11
miro_dietikerI think this looks pretty fine, didn't test though. Some small doc things.
This seems fine, but this extra check is so much important, you should add a comment here why...
You are not describing what the effective problem is - what specifically caused recusion. We should add comments that explain the problem.
Comment #12
toncic commentedChanged documentation for test functions and added more code comments to make code more understandable.
Comment #13
miro_dietikerSo, it sounds constructed, but the recursion could still indirectly happen if
A only allows B as child
And B only allows A child
;-)
We could only try to avoid that type of recursion by only allowing auto-population of each field once per host entity. Not sure what's the best definition.
Comment #14
toncic commentedYes, my solution is not working for these cases. We still get recursion.
Comment #15
toncic commentedAfter discussion with @Berdir, if these situation happen that is because wrong configuration. We don't want to try to fix wrong configuration, we just won't to prevent crushing. After adding 5 level of nesting we stopped adding default paragraph type and display warning.
Without interdiff because approach are totally different.
Comment #16
miro_dietikerI agree in general about "not fixing wrong config", but this behavior is the default behavior we propose if a paragraph type only supports itself as child type (until there is an opt-out). So it's likely not wrong custom config, but wrong default config. I'm not yet convinced to ignore that problem. ;-)
Comment #17
berdirWe could not make the default default type if it's the same as the parent, that might be possible.
But if it's not *wrong* configuration then it is at least weird configuration, because then you start mixing containers and content paragraphs, you can not have a container-only paragraphs using itself as its only child as then you would actually ever have anything to display. So it would be something like a text + child paragraph paragraph type.
Comment #18
miro_dietikerYeah, i also thought once that a container paragraph type can be clearly differentiated from a content paragraph type.
But sometimes, Containers could have content too and work without a child. At least (custom) compositions that have extra content fields (plus support children). I still think we need more examples to understand these things right.
Comment #19
primsi commentedWhat if we - instead of trying to figure out if we are in a recursion from the paragraph types - we just try to figure out if we are in a recursion, by setting some flag when we assign a default value for the first time. Not sure how should we do exactly, but it might be worth investigating a bit.
Comment #20
anand.toshniwal93 commentedI have re-rolled this patch against the 8.x-1.3 version
Comment #22
osab commentedHi! Maybe we should relate the issue https://www.drupal.org/project/paragraphs/issues/3022843 to the current one?
Comment #23
knieriem commentedSince this is related to https://www.drupal.org/project/paragraphs/issues/3022843, which has been marked closed, works as designed, can this be closed as well?