Problem/Motivation
FieldItemBase::setValue()
depends on the property definition order in some cases, for example when $entity->fieldname = 'somevalue';
is used or when setValue
is called with a scalar. The migration EntityContentBase::updateEntity
method often does the latter.
Steps to reproduce
Edit DateTimeItem::propertyDefinitions
and swap the definition of the two properties and watch DateTimeItemTest
fail.
Proposed resolution
Just call mainPropertyName()
. As far as I can tell, the main property name was introduced in #2015687: Convert field type to FieldType plugin for taxonomy module while using the "first property" notion was added a year before that in #1696640: Implement API to unify entity properties and fields and it was simply never updated.