An empty views pager offset field can cause a PHP type error to be triggered.

Created on 18 May 2023, almost 2 years ago

Problem/Motivation

I came across an intriguing bug in Drupal 10 views when configuring pager options. If the offset field is left empty, it triggers a PHP type error. In Drupal 10, the expected value for the offset field is 0, but when it is empty, it becomes offset: null instead.

TypeError: Cannot assign null to property Drupal\views\Plugin\views\query\QueryPluginBase::$offset of type int in Drupal\views\Plugin\views\query\QueryPluginBase->setOffset() (line 152 of core/modules/views/src/Plugin/views/query/QueryPluginBase.php).

Steps to reproduce

1. Enable views and views_ui module with D10.
2. Pick a views then set the `pager` - items to display (leave it as default), offset (default is 0, remove it so that the field is empty)
3. Save it (Click 'Apply'))
4. The PHP TypeError can be found in PHP logs.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.0

Component
Views 

Last updated 1 day ago

Created by

🇦🇺Australia pandaski

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

Comments & Activities

Production build 0.71.5 2024