Database query fails with negative pager

Created on 28 April 2020, over 4 years ago
Updated 20 October 2023, about 1 year ago

Problem/Motivation

When attempting to perform a database query with a negative pager value, the query execution fails, resulting in error. The issue arises due to the incorrect handling of negative pager values, which is not adequately accounted for in the current database query implementation. This can lead to unexpected behavior and hinder the proper functioning of the application, particularly when users attempt to navigate beyond the available range of data.

Steps to replicate the issue.

1. Visit a webpage using a pager
2. Add a page query parameter with a negative value, e.g. -1539
3. Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax

Proposed resolution

To address this issue, the database query implementation needs to be revised to handle negative pager values effectively. This involves implementing appropriate validation checks and error handling mechanisms to prevent the execution of database queries with negative pager values. Additionally, the system should be configured to provide informative error messages and log relevant details for debugging purposes. By ensuring robust validation and error handling, the application can maintain stability and data integrity, thereby delivering a seamless and reliable user experience.

Data model changes

we can introduce validation checks in the data model to ensure that any user inputs or parameters related to pager values are validated before executing database queries .
implement the error handling mechanism within the data model

Release notes snippet

None

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Base 

Last updated about 14 hours ago

Created by

🇧🇪Belgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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