PDOException (Numeric value out of range) when submitting a date after Jan 18, 2038

Created on 21 March 2023, over 1 year ago

Problem/Motivation

It looks like the same error that occurred in D7 #3070150: PDOException when submitting a date after Jan 18, 2038 is happening now in D9/10.

Steps to reproduce

On a standard profile drupal 9/10 install:
- Enable publication_date
- Go to /node/add/article, fill in title (required) and set the "Published on" field to e.g: 01/01/2040 01:00:00 AM
- Hit save and we get the following error
Drupal\Core\Entity\EntityStorageException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'published_at' at row 1: INSERT INTO "node_field_data" ("nid", "vid", "type", "langcode", "status", "uid", "title", "created", "changed", "promote", "sticky", "default_langcode", "revision_translation_affected", "published_at") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13); Array ( [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => 2 [:db_insert_placeholder_2] => article [:db_insert_placeholder_3] => en [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => qdqsd [:db_insert_placeholder_7] => 1679403104 [:db_insert_placeholder_8] => 1679403802 [:db_insert_placeholder_9] => 1 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 1 [:db_insert_placeholder_12] => 1 [:db_insert_placeholder_13] => 2208992400 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of /web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Proposed resolution

PublicationDateItem extends TimestampItem which defines a range (min/max) contraint in its annotation.
I'm guessing these contraints are therefore not inherited?
See if we can inherit the contraints from TimestampItem, otherwise redefine it.

Remaining tasks

Provide patch

User interface changes

?

API changes

?

Data model changes

?

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇪Belgium herved

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

Comments & Activities

  • Issue created by @herved
  • 🇧🇪Belgium herved

    Well, it looks like adding the constraint in the annotation is not enough.

    The logged violation gets removed in \Drupal\Core\Entity\EntityConstraintViolationList::filterByFieldAccess
    because the field edit access check returns FALSE
    because PublicationDateFieldItemList extends ChangedFieldItemList which defines defaultAccess() and returns a AccessResult:neutral() instead of allowed.

  • 🇧🇪Belgium herved

    Ok, here is a first draft but it all seems confusing.

Production build 0.71.5 2024