Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Now that #2232477: Fatal when adding new fields with NOT NULL constraints in a base table that contains existing entities leveraged the concpet of isRequired() on FieldItems' properties, this is what the base implementation of FieldItem::isEmpty() should rely on :
By default, an item is considered empty if any of its required properties is NULL.
Hopefully this should also let us remove a couple custom isEmpty() implementations in some field types.
Comment | File | Size | Author |
---|---|---|---|
#1 | 2401221-isEmpty_required_properties-1.patch | 609 bytes | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedStarter patch.
Still need to go through all current overrides and remove those that can be.
A few of them (EmailItem, TelephoneItem, TextItemBase / TextWithSummaryItem - most of those with a 'string' property, but surprisingly, *not* StringItem) additionally need to care for "empty if the value is NULL *or empty string*".
Wondering :
- whether it would make sense to code that specific behavior about 'string' properties directly in the base implementation of FieldItemBase::isEmpty()
- or whether that means an isEmpty() method on TypedData :-/
Comment #2
yched CreditAttribution: yched commented