Skip to content

Allow any value to be assigned to a content entity field property - #1100

Open
mstrelan wants to merge 1 commit into
mglaman:mainfrom
mstrelan:entity-field-writable-type
Open

mstrelan wants to merge 1 commit into
mglaman:mainfrom
mstrelan:entity-field-writable-type

Conversation

@mstrelan

Copy link
Copy Markdown
Contributor

Assigning a value to a field through the magic property is valid in Drupal, because ContentEntityBase::__set() passes the value to the field's setValue():

$node->title = 'foo';
$node->field_tags = [1, 2];

EntityFieldReflection::getWritableType() returned FieldItemListInterface for content entities, so each of these is reported:

Property Drupal\node\Entity\Node::$title (Drupal\Core\Field\FieldItemListInterface) does not accept string.

The method had a @todo asking whether this breaks that pattern. This changes the writable type to mixed. The readable type is unchanged.

Measured against Drupal core main without its baseline, over the 82 files that have this error in the baseline: 183 errors removed, none added. Core's baseline has 124 entries for this message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant