Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294185

Issues with Entity save checks regarding changed values.

$
0
0

Problem/Motivation

The Entity system has checks in place to reduce / optimize save operations, it seems to check whether an entity values have actually changed before performing a save, thus reducing unnecessary write operations.

These checks fail to detect a string field value change when the value was added leading zeros.

If I have defined an Entity's field as Text (plain) and assign a value of "1234", if I later change the value programmatically to "01234", a save operation is not triggered, while assigning a value of "0999" does.

"1234" and "01234" are not treated as different values even though the field is defined as string / text.

Steps to reproduce

1. Define a new Content Entity type with a field of type Text (plain)

2. Create a new entity, assigning "1234" as the field's value

3. Programmatically change the value to "01234" and save ($entity-save())

The save operations doesn't get triggered.

Proposed resolution

If a field is defined as text / string, the save checks on entities should treat "1234" and "01234" as different values.


Viewing all articles
Browse latest Browse all 294185

Trending Articles