Pager plugins do not validate input

Created on 16 February 2017, about 8 years ago
Updated 13 June 2023, almost 2 years ago

Problem/Motivation

The pager plugins, like Drupal\views\Plugin\views\pager\Some, do not validate input. #2847921: Use "number" form element in Views pager settings form will help ensure there are positive integers entered where required.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

9.5

Component
Views 

Last updated about 4 hours ago

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    Triaged as part of BSI

    A few of us agreed this needs some more actionable points. This seems like more of a theoretical thing that could lead to bugs? Also the mentioned issue is now closed. Should this be a task?

  • Status changed to Active 10 months ago
  • 🇳🇱Netherlands Lendude Amsterdam

    🌱 [meta] Add constraints to all config entity types Active only talks about the Views entity config, but ideally we should also implement constraints for all Views plugins, so repurposing this for that

  • First commit to issue fork.
  • Merge request !11809feat: add validation to pager schema's → (Open) created by bbrala
  • 🇳🇱Netherlands bbrala Netherlands
  • Pipeline finished with Failed
    13 days ago
    #471946
  • Pipeline finished with Success
    13 days ago
    Total: 494s
    #471947
  • 🇳🇱Netherlands bbrala Netherlands
  • Pipeline finished with Success
    13 days ago
    Total: 414s
    #471952
  • 🇮🇳India JatinGupta40

    Hello @bbrala
    Your MR looks good.
    But, I have one query. Currently, in Views configuration file, if the `offset` or `items_per_page` values are provided as strings (even though they should be integers), the configuration import (cim) works fine without any errors. However, when I open the view in the UI, these values appear as 0.

    Ideally, the system should throw an error during the config import itself, indicating that `offset` or `items_per_page` must be integers.

    So, moving this issue to Needs Work.

    Thanks.

  • 🇳🇱Netherlands bbrala Netherlands

    I tried to reproduce this, but eve if i import with a string it ends up as integer and i can do changes.

    Can you make a better reproduce step so i can see it locally?

  • 🇮🇳India JatinGupta40

    @bbrala Yes, you are right and you reproduced it correctly, that if we import it as a string, it ends up as interger, ie - 0.
    But i believe it would be better if we give an error message while importing, something like - String passed, expects integer value.

  • 🇳🇱Netherlands bbrala Netherlands

    Currently the validation is not enabled from the config import event. See 📌 Validate configuration schema before importing configuration Needs work . So your usecase is currently not supported. We can validate in the linked issue, but that would also now need to adjust to validate when we have a fully compatible and well defined schema for the config in question. Right now not all config is validatable yet, which would probably mean havoc everywhere.

    You say you get -0 as a result, or just 0? What is the value in the config you have? Since -0 does feel impossible to set through UI.

  • Pipeline finished with Success
    7 days ago
    Total: 675s
    #477143
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    items_per_page and pagination_heading_level are removed from the views_pager_sql schema, but I don't see a reason for that in the issue, can you help me understand this?

  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    Updated the page title to be in line with most of the other issues in the validation space.

  • 🇳🇱Netherlands bbrala Netherlands

    The parent type has these fields.

    views_pager_sql:
      type: views_pager
    

    views_pager has and validated those fields. The views_pager_sql extends the earlier type and adds more, but also still has the existing fields afaik.

Production build 0.71.5 2024