Add validation constraints to views.settings

Created on 15 April 2024, 3 months ago
Updated 8 July 2024, 10 days ago

Problem/Motivation

views.settings has property paths that are not yet validatable:

./vendor/bin/drush config:inspect --filter-keys=views.settings --detail --list-constraints                 
โžœ  ๐Ÿค– Analyzingโ€ฆ

 Legend for Data: 
  โœ…โ“  โ†’ Correct primitive type, detailed validation impossible.
  โœ…โœ…  โ†’ Correct primitive type, passed all validation constraints.
 --------------------------------------------------- --------- ------------- ------ -------------------------------------------- 
  Key                                                 Status    Validatable   Data   Validation constraints                      
 --------------------------------------------------- --------- ------------- ------ -------------------------------------------- 
  views.settings                                      Correct   31%           โœ…โ“   ValidKeys: '<infer>'                        
                                                                                     LangcodeRequiredIfTranslatableValues: null  
   views.settings:                                    Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                        
                                                                                     LangcodeRequiredIfTranslatableValues: null  
   views.settings:_core                               Correct   Validatable   โœ…โœ…   ValidKeys:                                  
                                                                                       - default_config_hash                     
   views.settings:_core.default_config_hash           Correct   Validatable   โœ…โœ…   NotNull: {  }                               
                                                                                     Regex: '/^[a-zA-Z0-9\-_]+$/'                
                                                                                     Length: 43                                  
                                                                                     โ†ฃ PrimitiveType: {  }                       
   views.settings:display_extenders                   Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements              Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.address      Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.article      Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.aside        Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.blockquote   Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.code         Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.del          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.details      Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.div          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.em           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.figure       Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.footer       Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.h1           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.h2           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.h3           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.h4           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.h5           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.h6           Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.header       Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.ins          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.kbd          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.p            Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.pre          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.q            Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.s            Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.samp         Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.section      Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.span         Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.strong       Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:field_rewrite_elements.var          Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:sql_signature                       Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui                                  Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                        
   views.settings:ui.always_live_preview              Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.exposed_filter_any_label         Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
   views.settings:ui.show                             Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                        
   views.settings:ui.show.additional_queries          Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.advanced_column             Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.default_display             Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.display_embed               Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.performance_statistics      Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.preview_information         Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.sql_query                   Correct   Validatable   โœ…โœ…   ValidKeys: '<infer>'                        
   views.settings:ui.show.sql_query.enabled           Correct   Validatable   โœ…โœ…   โ†ฃ PrimitiveType: {  }                       
   views.settings:ui.show.sql_query.where             Correct   NOT           โœ…โ“   โš ๏ธ  @todo Add validation constraints here   
 --------------------------------------------------- --------- ------------- ------ -------------------------------------------- 

Steps to reproduce

  1. Get a local git clone of Drupal core 11.x.
  2. composer require drupal/config_inspector โ€” or manually install https://www.drupal.org/project/config_inspector/releases/2.1.5 โ†’ or newer (which supports Drupal 11!)
  3. composer require drush/drush
  4. vendor/bin/drush config:inspect --filter-keys=views.settings --detail --list-constraints

Proposed resolution

Add validation constraints and mark FullyValidatable.

For examples, search *.schema.yml files for the string constraints: ๐Ÿ˜Š

Reach out to @borisson_ or @wimleers in the #distributions-and-recipes.

Remaining tasks

User interface changes

None.

API changes

Data model changes

More validation ๐Ÿš€

Release notes snippet

None.

๐Ÿ“Œ Task
Status

Postponed

Version

10.3 โœจ

Component
Viewsย  โ†’

Last updated about 6 hours ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia narendraR Jaipur, India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @narendraR
  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 1082s
    #166928
  • Pipeline finished with Failed
    2 months ago
    Total: 702s
    #167455
  • Pipeline finished with Failed
    2 months ago
    Total: 738s
    #167485
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    YAY! Welcome, @mikelutz! ๐Ÿ˜„๐Ÿฅณ Unfortunately GitLab seems to just have gone down!?! ๐Ÿ˜ฑ I'm getting 503s!

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium Wim Leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Excellent start! Thanks for helping out making all of Drupal core's config validatable! I left some pointers in my review on the merge request ๐Ÿ˜Š

  • Pipeline finished with Failed
    2 months ago
    Total: 664s
    #167654
  • Pipeline finished with Failed
    2 months ago
    Total: 604s
    #167696
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mikelutz Michigan, USA

    The test failure is on the display_extenders section. It's a sequence of enabled display_extender plugins, but it's inserted directly from the form values of a mulit-checkbox element. So enabled plugins look like "plugin_id: plugin_id" and disabled plugins look like "plugin_id: '0'". As it is now, validation would mean the value is either an existing display_extender plugin OR the string "0". So the question is do we write that, maybe as an extra option to PluginExists, or a one-off for this situation for views that can be used with the Choice constraint? Or do we start array_filtering the values from the form before storing them, and add an update hook to clean up existing configs first?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    scott_euser โ†’ changed the visibility of the branch 3440962-add-validation-constraints to hidden.

  • Status changed to Postponed 10 days ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    Okay I created ๐Ÿ› Views display extenders should only save enabled extenders Needs review to prove that display_extenders issue + sort it with the array_filter. We are already filtering them on load in Drupal\views\Views::getEnabledDisplayExtenders() so it seems logical to filter them out on save. To avoid a more complicated update, I think it does not hurt to keep the array filter in the ::getEnabledDisplayExtenders().

    So I think this is postponed until ๐Ÿ› Views display extenders should only save enabled extenders Needs review gets merged right?

Production build 0.69.0 2024