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.
Problem/Motivation
filter.module defines a generic schema, but that only works as long as you just store strings. When you no longer do, it falls apart.
That is not only uncommon (everywhere else, we force plugins to define a schema), it is also confusing.
Proposed resolution
Change filter_settings.*: to type mapping with an empty mapping. Anything that has settings then needs to provide a schema.
Comments
Comment #1
cburschkaI can confirm that it was pretty confusing when my filter plugin worked normally until I tried to store a nested mapping. This patch changes the settings to a simple mapping.
While looking at this schema, I don't think I fully understand why the core filter plugin settings use the type "filter", which seems to define an entire filter rather than just its settings.
Comment #2
BerdirYes, type:filter is weird, that looks wrong.
Can you change that to type: mapping. Making that type: filter is actually recursive o.0
Comment #3
cburschkaYep
Comment #4
alexpottNeed to fix filter_settings.filter_test_restrict_tags_and_attributes in core/modules/filter/tests/filter_test/config/schema/filter_test.schema.yml as well otherwise this fix is looking good.
Comment #5
jgeryk CreditAttribution: jgeryk commentedComment #6
jgeryk CreditAttribution: jgeryk commentedupdated filter_test_schema
Comment #7
alexpottThis looks like unrelated change - how come its been changed?
Comment #8
alexpottSorry I should have been clearer in #4 that all that needs to change is the
type: filter
- the rest offilter_settings.filter_test_restrict_tags_and_attributes
is correct.Comment #10
subhojit777Comment #13
quietone CreditAttribution: quietone as a volunteer commentedRetesting on 8.2.x
Comment #14
quietone CreditAttribution: quietone as a volunteer commentedTests pass on 8.2.x. The points raised in #2 and # 4 are fixed in the latest patch. So all looks good. I'd RTBC except that I wonder if this needs any tests.
Does this need a test?
Comment #15
cburschkaNote: I'm not sure this can still go in the next 8.2.x release, since it introduces an API problem for modules that relied on the old schema before.
Comment #16
BerdirThat is a good question, I'm not sure. I do think this is a bug and invalid/missing schema only causes a hard fail in tests (for now). So it might be OK.
That said, we definitely need a change record for this.
Comment #17
quietone CreditAttribution: quietone as a volunteer commentedRemoving novice tag due to the need of a change record per Berdir's comment in #16 and addressing the API problem mentioned in #15.