- Merge request !306chore(Shape matching): test JsonSchemaFieldInstanceMatcher against bundle fields β (Open) created by mglaman
Encountered this when working with Acquia DAM and Content Templates. There was a field on the Article content type that referenced Acquia DAM media types and the normal image/video media types. Canvas was failing over the bundle fields on the Acquia DAM media types. I feel like there may be another way to reproduce, but this was how we triggered.
When loading a form for a component a 500 error was returned:
Error 500: Field acquia_dam_alt_text does not exist on entity:media:acquia_dam_image_asset entities.
But the field definitely exists in the bundle's field definitions. In \Drupal\canvas\ShapeMatcher\JsonSchemaFieldInstanceMatcher::matchEntityPropsForScalar there is logic to map bundles from a reference fields settings:
// When >1 bundle is specified, the above only matched base fields.
// Iterate over all possible target bundles, set each on a clone of
// $target, and hence repeat the same process as above β but exclude
// base fields that are re-matched.
// @see \Drupal\Core\Entity\TypedData\EntityDataDefinition::getPropertyDefinitions()
$target_bundles = $field_definition->getItemDefinition()->getSettings()['handler_settings']['target_bundles'] ?? [];
if (count($target_bundles) > 1) {
$base_field_names = array_keys($target->getPropertyDefinitions());
foreach ($target_bundles as $target_bundle) {
assert($target->getBundles() === NULL);
This code clones the entity data definition and sets the bundle explicitly for the target bundle. The problem is that cloning EntityDataDefinition does not reset the values in \Drupal\Core\TypedData\ComplexDataDefinitionBase::$propertyDefinitions which act as an object cache.
The fix is to skip cloning and create a new value object:
$bundle_specific_target = EntityDataDefinition::create($target->getEntityTypeId(), $target_bundle);
Active
1.0
Shape matching
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.