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.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cburschka’s picture

Status: Active » Needs review
FileSize
514 bytes

I 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.

config/schema/core.data_types.schema.yml

filter_settings.filter_html:
  type: filter
  label: 'Filter HTML'
  mapping:
    allowed_html:
      type: string
      label: 'Allowed HTML'
    filter_html_help:
      type: boolean
      label: 'HTML help'
    filter_html_nofollow:
      type: boolean
      label: 'HTML nofollow'


filter_settings.filter_url:
  type: filter
  label: 'Filter URL'
  mapping:
    filter_url_length:
      type: integer
      label: 'URL length'
config/schema/core.data_types.schema.yml

# Filter with module and status.
filter:
  type: mapping
  label: 'Filter'
  mapping:
    id:
      type: string
      label: 'ID'
    provider:
      type: string
      label: 'Provider'
    status:
      type: boolean
      label: 'Status'
    weight:
      type: integer
      label: 'Weight'
    settings:
      type: filter_settings.[%parent.id]
Berdir’s picture

Status: Needs review » Needs work

Yes, type:filter is weird, that looks wrong.

Can you change that to type: mapping. Making that type: filter is actually recursive o.0

cburschka’s picture

Status: Needs work » Needs review
FileSize
759 bytes

Yep

alexpott’s picture

Status: Needs review » Needs work

Need 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.

jgeryk’s picture

Assigned: Unassigned » jgeryk
jgeryk’s picture

Assigned: jgeryk » Unassigned
Status: Needs work » Needs review
FileSize
1.87 KB

updated filter_test_schema

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/modules/filter/tests/filter_test/config/schema/filter_test.schema.yml
@@ -1,22 +1,16 @@
       mapping:
         allowed:
-          type: sequence
+          type: mapping
           label: 'Allowed tags and attributes'
-          sequence:
-            type: ignore
-            label: 'Tag and optionally list of attributes'
         forbidden_tags:
-          type: sequence
+          type: mapping
           label: 'Forbidden tags'
-          sequence:
-            type: boolean
-            label: 'Tag'

This looks like unrelated change - how come its been changed?

alexpott’s picture

Sorry I should have been clearer in #4 that all that needs to change is the type: filter - the rest of filter_settings.filter_test_restrict_tags_and_attributes is correct.

The last submitted patch, 6: drupal.filter_settings_default_schema_2472927_6.patch, failed testing.

subhojit777’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Retesting on 8.2.x

quietone’s picture

Tests 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?

cburschka’s picture

Note: 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.

Berdir’s picture

That 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.

quietone’s picture

Status: Needs review » Needs work
Issue tags: -Novice +Needs change record

Removing novice tag due to the need of a change record per Berdir's comment in #16 and addressing the API problem mentioned in #15.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.