Problem/Motivation
The configuration schema declares the sections option of the Bootstrap Accordion with an invalid data type:
https://git.drupalcode.org/project/views_bootstrap/-/blob/5.5.2/config/s...
views.style.views_bootstrap_accordion:
...
sections:
type: array
label: "Open Elements"
items:
type: string
default: []
array is not a Drupal configuration schema data type, and items / default are not part of the configuration schema language (they belong to JSON Schema). Drupal only knows the primitive types plus mapping and sequence.
As a result, TypedConfigManager::determineType() cannot resolve the type and falls back to undefined, so the element is an Undefined object and SchemaCheckTrait::checkValue() reports missing schema for that key.
Steps to reproduce
- Install Drupal 10.1+/11 and Views Bootstrap 5 (5.5.2); enable
views_bootstrap,views_ui. - Create a view with a page or block display, set Format to Bootstrap Accordion, select a Panel title field and save the view.
- Export the configuration (
drush config:export) and confirm the display options contain asectionskey. - Install the Configuration Inspector module and visit /admin/config/development/configuration/inspect, or run
drush config-inspector:inspect views.view.YOUR_VIEW. The view is listed with errors and the detail is:
views.view.YOUR_VIEW:display.default.display_options.style.options.sections missing schema - Re-import the configuration (
drush config:import): the same schema validation warnings are raised for every configuration object that uses this style. - Alternatively, in a kernel test with
protected $strictConfigSchema = TRUE;(the default), save a view using the Bootstrap Accordion style: the test fails withSchemaIncompleteException.
Proposed resolution
Fix the schema definition in config/schema/views_bootstrap.style.schema.yml so that the sections option uses a valid Drupal configuration schema type. The attached patch:
- replaces
type: arraywithtype: sequence, the correct type for a list of values in Drupal configuration schema; - replaces the
items:key with the requiredsequence:key, keepingtype: stringfor the items; - removes
default: [], which has no meaning in configuration schema — the default already belongs to the style plugin, which declares$options['sections'] = ['default' => []]inViewsBootstrapAccordion::defineOptions().
sections:
type: sequence
label: "Open Elements"
sequence:
type: string
With this change the key resolves to a Sequence of strings. A sequence accepts string keys (core itself does this, e.g. core.extension:module), so the values produced by the checkboxes element (first, middle, last) remain valid, and the unchecked value 0 as well as the checked value (the option key) are both covered by string.
The missing schema errors disappear, the values are properly cast on save/export, and no PHP code change or update path is required.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
No change to the stored configuration structure: the sections key and its first / middle / last entries are unchanged. Only the schema definition changes, so the values are now typed and cast as strings (for example 0 becomes '0') the next time the view is saved or exported. Existing configuration remains valid and no update path is required.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | views_bootstrap-invalid-schema-sections-3614624-4.patch | 531 bytes | lolgm |
Issue fork views_bootstrap-3614624
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
lolgm commentedMR !64 implements the proposed solution in this issue.
Comment #6
shelaneThanks