Problem/Motivation

The function function _workflow_info_fields() return all Workflow Fields for the entity at hand.
For this, it runs $entity?->{$field_name};.
However, this invokes a createItem() on the FieldItemList.
- This is bad DX, since extra calls are made.
- Perhaps bad for performance
- It manipulates default code, unnecessarily.
Not sure if this was always the case (since D8) or introduced in a later Drupal version.

Steps to reproduce

Proposed resolution

Replace the 'magic' function call $entity?->{$field_name};
by $entity->hasField($field_name).
It has the same result, without the side effects.

Comments

johnv created an issue.

  • johnv committed 3056a121 on 2.1.x
    Issue #3590383: Avoid ::createItem when inspecting fields