CreatedItem and ChangedItem are missing TimestampItem's Range constraint

Created on 24 April 2025, 1 day ago

Problem/Motivation

Timestamp fields have a range constraint so that no value outside of the range of the database storage can be saved. The changed and created field types extend the timestamp field type but are missing that constraint. That means that invalid created or changed values that enter the system via a migration or JSON:API, for example, are not properly validated and may cause exceptions when being saved.

Steps to reproduce

$node = Node::create([
  'title' => 'Back to the future',
  'type' => 'article',
  // This is not a 32-bit integer.
  'created' => 2147483649
]);
// This yields 0, thus no violation is recorded.
$node->validate()->count();
// Brace for SQL exception.
$node->save();

Proposed resolution

Copy the constraints over from TimestampItem to CreatedItem and ChangedItem.

Remaining tasks

User interface changes

-

Introduced terminology

-

API changes

-

Data model changes

-

Release notes snippet

-

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

field system

Created by

🇩🇪Germany tstoeckler Essen, Germany

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

Comments & Activities

Production build 0.71.5 2024