Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We save all form values, even if they're empty, which is quite common for optional behavior plugins.
We should probably at least put an array_filter() around it.
Comment | File | Size | Author |
---|---|---|---|
#17 | 2884236-17.patch | 6.02 KB | VladimirMarko |
| |||
#17 | interdiff-2884236-12-17.txt | 737 bytes | VladimirMarko |
#17 | 2884236-17-test-only.patch | 3.74 KB | VladimirMarko |
Comments
Comment #2
miro_dietikerIs this duplicate?
#2884131: Sort behavior plugins by weight
Comment #3
BerdirComment #4
BerdirActually it is not. That is about paragraph type settings, this about paragraph settings.
Comment #5
miro_dietikerPlugins should not be called if they are disabled. Thus there is no dependency to anything like default configuration.
If anything, we should make sure default configuration is only applied and required if it is enabled.
This is polluting the content storage and making our life harder. We should really try to clean this.
Comment #6
tbonomelli CreditAttribution: tbonomelli at MD Systems GmbH commentedComment #7
tbonomelli CreditAttribution: tbonomelli at MD Systems GmbH commentedComment #8
VladimirMarko CreditAttribution: VladimirMarko at MD Systems GmbH commentedAs we cannot know what a plugin considers to be a default value,
ParagraphsBehaviorBase
now considers all empty values to be default and won't save them.If a behavior plugin wants to distinguish between different empty values, it will have to override either the
submitBehaviorForm
method or at least the newfilterBehaviorFormSubmitValues
method.Comment #9
Berdirtypo: iff
recursively removed is an implementation detail, that's not part of the API and shouldn't be mentioned here.
This needs a comment. Also not convinced that we need to pass in $values *and* $form_state, if you pass in $form_state it is easy enough to call getValues() on it.
strange that the parent doesn't have the nesting and filtering itself reversed, then this loop wouldn't be necessary.
We should be able to test this by checking what gets saved by our test plugins and maybe add a nested example if we don't have that yet.
Comment #10
VladimirMarko CreditAttribution: VladimirMarko at MD Systems GmbH commentedHere you go.
Comment #11
miro_dietikerThat test-only was supposed to fail i guess? :-)
Comment #12
VladimirMarko CreditAttribution: VladimirMarko at MD Systems GmbH commentedYeah. The test class was wrongly namespaced.
I also fixed some coding standards violations.
Comment #14
miro_dietikerSo we are removing empty values only, and recursively.
It also seems that keys with assigned values FALSE (array_filter()) are removed.
But it also seems that if a plugin provides default values, those are stored.
Not sure if this is what we exactly want and what are our options. Thinking about it:
Say, for instance, if a plugin proposes that a setting is enabled by default, that setting is present in all paragraph types by default value even if the plugin is not enabled. This seems odd, right?
Comment #15
VladimirMarko CreditAttribution: VladimirMarko at MD Systems GmbH commented@miro_dietiker:
There's not much we can do about that. Plugins define their settings themselves and we cannot know what any given plugin considers to be its default settings without manually inspecting its
buildBehaviorForm
method.(Or doing something really dodgy like cloning its Paragraph, removing its current plugin settings and building, validating and submitting a new settings form for it.)
The problem is that we have provided a default implementation of
submitBehaviorForm
inParagraphsBehaviorBase
that stores all the settings from the form and most plugin authors did not see the need to override that method to reduce the amount of junk settings their specific plugin stores.So to do anything at all, this patch needs to be opinionated about what constitutes default settings. If a behavior plugin author disagrees with this opinion, he should either override
ParagraphsBehaviorBase::submitBehaviorForm
, overrideParagraphsBehaviorBase::filterBehaviorFormSubmitValues
, or not useParagraphsBehaviorBase
at all.Comment #16
Berdirstrange trailing slash, also this relies on the feature that it redirects to the single node type if there is only one. lets save a redirect and go to the form directly.
Comment #17
VladimirMarko CreditAttribution: VladimirMarko at MD Systems GmbH commentedComment #19
Berdir@Miro: I think you might have tested the wrong thing here. This is about the per-paragraph behavior settings, there is no such thing as disabled plugins here.
What you are looking for is #2884131: Sort behavior plugins by weight, which should solve the problem of disabled plugin configuration.
Comment #21
miro_dietikerOh :-) committed.