I have the issue #1923328: Notice: Undefined property: stdClass::$field_tags in linkchecker that I do not understand yet and I need some help about this field issue.
If a new article node is added (via node/add
) the field_tags
field is completely missing in the $entity
. This seems not happen if you edit the node later (node/edit
). I get a notice for line $entity->$field['field_name'];
, but I think this field_name must always exists in the entity. I cannot find any other example in core that handle or workaround this type of notices.
Code example:
<?php
// Collect the fields from this entity_type and bundle.
foreach (field_info_instances($entity_type, $bundle_name) as $field_name => $instance) {
$field = field_info_field($field_name);
// #1923328: field_name array may be missing in $entity if field is empty.
$entity_field = $entity->$field['field_name'];
...
?>
What's wrong here?