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.
Issue fork viewsreference-3490315
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
trackleft2Comment #5
scott_euser commentedThanks for this! Confirmed that core Views pager that this modifies does also have a min of 0, so we are safe to mimic that
Also thanks for adding test to both of these!