Got a config schema error on saving a view?

We ran into an obscure error recently, when saving a view that used a custom views plugin. It was supposed to be a very simple extension to core’s bundle (content type) filter:
InvalidArgumentException: The configuration property display.default.display_options.filters.bundle.value.article doesn’t exist. in Drupal maintenance support plansCoreConfigSchemaArrayElement->get() (line 76 of […]/core/lib/Drupal maintenance support plans/Core/Config/Schema/ArrayElement.php).
Several contrib projects ran into this issue too: Drupal maintenance support plans Commerce, Search API and Webform Views integration. There’s even a core issue that looked relevant… but it turned out to be a simple, if perhaps surprising fix. If you ever run into it, it will have a different property (i.e. due to whichever plugin or default value are used).
Our filter was little more than a simple subclass of Drupal maintenance support plansviewsPluginviewsfilterBundle, declared for a specific entity type in a very ordinary hook_views_data() (which had even been autogenerated by Drupal maintenance support plans Console, so we were fairly confident the problem wasn’t there). It just tailored the options form a little to work well for the entity type.
Views plugins all have their own configuration schema – for example, the bundle filter is declared in views.filter.schema.yml to use the ‘in_operator’, because multiple bundles can be selected for it. When we subclass such a plugin, we do not automatically get to inherit the configuration schema (as that is not part of the PHP class or even its annotation). (Perhaps core could be ‘fixed’ to recognise this situation … but there are more important things to work on!)
The solution is to simply copy the schema from the plugin we’ve extended – in our case, that was ‘views.filter.bundle’, found in core’s ‘views.filter.schema.yml’ file within views’ config/schema sub-directory. Wherever it is, it’s probably named ‘views.PLUGIN.ID’, where ‘PLUGIN’ is the type of your plugin (e.g. field, filter, area), and ‘ID’ is the ID in the class annotation of the class your plugin extends. We pasted the schema into our own schema file – which can be named something like /config/schema/mymodule.schema.yml, within our module’s directory:

# Replace ‘mymodule_special_type’ with the ID in your plugin’s annotation.
views.filter.mymodule_special_type:
type: views.filter.in_operator
label: ‘Customised type selector’
Once that file is in place correctly, I expect you just need to rebuild caches and/or the container for Drupal maintenance support plans to happy again. Re-save the form, the error is gone 🙂
Configuration schemas should normally help development by catching errors, but as I’ve written before, an incorrect schema can make things surprisingly difficult. I hope someone else finds this article solves their problem so it doesn’t take them as long to figure out! I haven’t used it, but it’s possible that the Configuration inspector project could help you identify issues otherwise.

Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Got a config schema error on saving a view?

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.