NumericFilter base class, when no entities available, sets the default value min, max value causing a php error.

Created on 16 January 2023, almost 2 years ago
Updated 31 August 2023, over 1 year ago

Problem/Motivation

The NumericFilter class which the GlobalFilter views filter plugin extends from, seems to be causing some php error, which prevents you from adding and configuring a global filter in the views ui.

Steps to reproduce

  1. Install simple_global_filter
  2. Create a global filter by going to /admin/structure/global_filter
  3. Go to a view and try to add this global filter. After selecting it, when you try to click on the "Add and configure filter view", nothing happens because of an error in the backend.

Proposed resolution

After some debugging, I found out that the root cause of this was the fact that the GlobalFilter plugin is extending from the NumericFilter class which provides this default value


    $options['value'] = [
      'contains' => [
        'min' => ['default' => ''],
        'max' => ['default' => ''],
        'value' => ['default' => ''],
      ],
    ];

in its defineOptions method. This value gets passed as an id to EntityStorageBase's load function which causes an error.

The proposed solution is to not use NumericFilter as the base class of GlobalFilter, and use FilterPluginBase instead. I will be posting a patch

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024