Trying to fix another issue I was debugging code in the 10.3.x/11.x feature "Expose all fields as blocks to Layout Builder". The FieldBlockDeriver->getFieldMap()
isn't cleaning up the array as effectively as it could be.
Drupal\layout_builder\Plugin\Derivative\FieldBlockDeriver->getFieldMap(), line 198
has the following:
$field_map[$entity_type_id][$field_name]['bundles'] = array_intersect($field_info['bundles'], $layout_bundles[$entity_type_id]);
// If no bundles are using Layout Builder, remove this field from the
// field map.
if (empty($field_info['bundles'])) {
unset($field_map[$entity_type_id][$field_name]);
}
The comparison for `empty()` is not checking the array that has been altered, but instead checking the in memory version from when the array loop was created. Can be confirmed with debugging tools, or checking output of ->getFieldMap()
.
Replace empty($field_info['bundles'])
with empty($field_map[$entity_type_id][$field_name]['bundles'])
.
PR to follow.
None.
None.
->getFieldMap()
would return less items after the change, but the items would be the expected ones.
None.
Further reduced the automatically derived blocks for layout builder.
Active
11.0 π₯
Last updated