Negative value in "items per page" triggers fatal error.

Created on 27 November 2024, 4 months ago

Problem/Motivation

When accidentally setting a negative value in the items per page field when referencing a view, I was presented with a fatal error whitescreen along with this in the log.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in [module_name]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-3 OFFSET 0' at line 10.

Steps to reproduce

Set a negative value in the items per page field when referencing a view.

Proposed resolution

Set a minimum limit of zero to the limit field.
See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
See https://git.drupalcode.org/project/viewsreference/-/blob/8.x-2.x/src/Plu...

Remaining tasks

Create a merge request

User interface changes

You are no longer able to set negative values in the limit field.

API changes

Negative values should no longer be accepted in the limit field.

Data model changes

Negative values should no longer be accepted in the limit field.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024