The following error occurs:
( ! ) Fatal error: Uncaught TypeError: Argument 1 passed to Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() must be of the type array, null given, called in /web/modules/contrib/block_field/src/Plugin/Field/FieldFormatter/BlockFieldLabelFormatter.php on line 40 and defined in /web/core/lib/Drupal/Core/Cache/CacheableMetadata.php on line 149
In BlockFieldLabelFormatter its stated:
CacheableMetadata::createFromRenderArray($elements[$delta]['content'])
But the element's render array is:
$elements[$delta] = [
'#markup' => $block_instance->label(),
];
This merge statement looks to be a mistake.
Comments
Comment #2
ieguskiza commentedHi, I added some tests to verify the issue. I attach a patch with only the test so it fails an another with the solution.
Comment #3
ieguskiza commentedI noticed that my first proposal has a hard dependency on versions of Drupal higher than 8.8. I attach another patch that is compatible with previous releases since I'm not sure what the appropriate approach is here.
Comment #4
chewie commentedPatch looks good for me.
Comment #5
sardara commentedIsn't "block_field_test" the bundle name?
Let's put just a single empty line.
For the rest it looks good!
Comment #6
sardara commentedComment #7
ieguskiza commentedHi @sardara, here are the patches with all the changes you proposed. I also added an interdiff for all of them.
Comment #8
ieguskiza commentedComment #9
ieguskiza commentedIt was brought to my attention that I left some spaces on the 8.7 compatible patch. I upload here another version without the spaces.
Comment #10
sardara commentedLooks good! Moving to RTBC.
Comment #11
mpp commentedThis is causing a fatal error without a workaround, setting to critical.
RTBC++
Comment #12
mpp commentedAdding the complete error message for people to find this issue more easily.
Comment #13
tim-dielsphpcs: Line exceeds 80 characters; contains 82 characters
@deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use EntityDisplayRepositoryInterface::getViewDisplay() instead.
This patch needs a re-roll for Drupal 8.8+
Comment #14
sardara commentedIt's present from 8.8, but not in 8.7. This module still reports compatibility with ^8.7.7, we shouldn't drop it for a test. Let's change the code to make it work and support 8.7 and 9.0.
Comment #15
tim-dielsPatch and interdiff provided
Comment #16
afireintheattic commentedJust tested the patch in #15 and it works great for me. Thanks!
Comment #17
paulocsMoving to needs review so tests can be added.
Comment #19
berdirLooks good to me and has a test. Committed.
Comment #20
berdir