Repository navigation
Conversation
Stored field item properties are NULL on items from appendItem() and on unsaved entities. Core's isEmpty() implementations check for NULL, so the stubs now declare these properties as nullable, matching the PathItem, TextItemBase and TelephoneItem stubs. - StringItemBase, EmailItem, DecimalItem, LanguageItem: ?string $value - IntegerItem, BooleanItem, TimestampItem: ?int $value - FloatItem: ?float $value - LinkItem: ?string $uri, ?string $title - FileItem: ?string $description, ?bool $display Fixes mglaman#1078
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1078
Stored field item properties can be
NULL, for example on items fromappendItem()or on unsaved entities, and core'sisEmpty()implementations check forNULL. This PR makes the stored properties listed in the issue nullable, matching thePathItem,TextItemBaseandTelephoneItemstubs.StringItemBasevaluestring?stringEmailItemvaluestring?stringDecimalItemvaluestring?stringIntegerItemvalueint?intFloatItemvaluefloat?floatBooleanItemvalueint?intTimestampItemvalueint?intLanguageItemvaluestring?stringLinkItemuri,titlestring?stringFileItemdescriptionstring?stringFileItemdisplaybool?boolSubclasses pick up the change through inheritance:
StringItem,StringLongItem,UriItem,UuidItemandPasswordItemfromStringItemBase, andChangedItemandCreatedItemfromTimestampItem. The matching assertions intests/src/Type/data/field-types.phpnow include|null.I left out the "Needs a closer look" items (
LanguageItem::$language,LinkItem::$options,PasswordItem::$pre_hashed,MapItem::$value), since they weren't confirmed. I can cover them in a follow-up.Effect on the Drupal core baseline check
The "Drupal core HEAD baseline check" job reports 7 errors on this PR. Four of them come from
DecimalItem::preSave()(core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php:113), which callsround($this->value, ...). Core's baseline has two entries for that line, and their messages include the old type:Parameter #1 $num of function round expects float|int, string given.Property ...\DecimalItem::$value (string) does not accept float.With this change, the same two errors are reported with
string|nullin the message. The old entries no longer match, so the job reports both errors plus two unmatched baseline entries. Core would need to regenerate those two entries. The other three errors are unmatched baseline entries that also fail onmain.