Issue #1470236 by iamEAP, mstrelan, poker10, divesh.kumar: Array flip error when a taxonomy term field has a NULL value

merge-requests/4116/head
Juraj Nemec 2023-05-26 18:53:32 +02:00
parent 7c73718bac
commit f1199f88e5
No known key found for this signature in database
GPG Key ID: 01EC3E1EECB5B2CA
2 changed files with 8 additions and 1 deletions

View File

@ -1684,7 +1684,7 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field,
}
}
if ($tids) {
$terms = taxonomy_term_load_multiple($tids);
$terms = taxonomy_term_load_multiple(array_filter($tids));
// Iterate through the fieldable entities again to attach the loaded term data.
foreach ($entities as $id => $entity) {

View File

@ -1698,6 +1698,13 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase {
$entity = field_test_entity_test_load($entity->ftid);
field_test_entity_save($entity);
$this->pass('Empty term ID does not trigger autocreate.');
// Try also NULL value.
$entity->{$this->field_name}[$langcode][0]['tid'] = NULL;
field_test_entity_save($entity);
$this->pass('NULL term ID does not trigger autocreate.');
field_attach_prepare_view('test_entity', array($entity->ftid => $entity), 'full');
$this->pass('NULL term ID prepared to display.');
}
}