Negative value in "Offset results" triggers fatal error.

Created on 27 November 2024, 4 months ago

Problem/Motivation

When entering a negative value in the "Offset results" field while referencing a view I see an error upon save and redirect to node with the view embedded.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in [Custom Module]:
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 at line 10:

Query

SELECT DISTINCT
  "node_field_data"."title" AS "node_field_data_title",
  "node_field_data"."nid" AS "nid",
  "author_data"."id" AS "author_data_id",
  DATE_FORMAT(node__publication_date.field_publication_date_value, '%Y%m%d') AS "formatted_publication_date"
FROM "node_field_data"
LEFT JOIN "node__authors" ON node_field_data.nid = node__authors.entity_id
  AND (node__authors.deleted = :join_condition_0 AND node__authors.langcode = node_field_data.langcode)
LEFT JOIN "author_data" ON node__authors.field_authors_target_id = author_data.id
INNER JOIN "node__publication_type" ON node_field_data.nid = node__publication_type.entity_id
  AND (node__publication_type.deleted = :join_condition_2 AND node__publication_type.langcode = node_field_data.langcode)
LEFT JOIN "node__publication_date" ON node_field_data.nid = node__publication_date.entity_id
  AND (node__publication_date.deleted = :join_condition_4 AND node__publication_date.langcode = node_field_data.langcode)
WHERE
  ("node_field_data"."status" = :status_condition)
  AND ("node_field_data"."type" IN (:type_condition))
  AND ((node__publication_type.field_publication_type_value = :publication_type_value))
ORDER BY "formatted_publication_date" DESC, "node_field_data_title" ASC
LIMIT 25 OFFSET -3;

Steps to reproduce

Reference a view
In the Options dropdown add a negative value to the Offset results field.

Proposed resolution

Set a minimum value of 0 on the field.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› 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