Metatags ItemList Delta Incorrect

Created on 26 September 2018, about 6 years ago
Updated 24 January 2024, 10 months ago

There is an issue with the built in MetatagsFieldProcessor when it creates field data. The existing code does not put the metatag field data within a numeric index, for metatags this is index/delta 0 since the field is never multivalued. This becomes a problem when you click Preview because the ContentTranslationPreviewController attempts to loop over every field (metatags included) and set the translation for each index/delta field value.

The code path is ContentTranlsationPreviewController::makePreview calls $translation->get('field_metatags')->offsetGet('basic') where 'basic' should be the numeric delta/index of the field. This makes its way through the Drupal API until it gets to an InvalidArgumentException from Drupal\Core\TypedData\Plugin\DataType\ItemList:get.

In other words, say you have a plain text field named "heading" and a plain text field named "metatags." The plain text field will store as follows,

title
- 0
  - value
    - #text: field contents
    - #translation
      - #text: translated field contents

But, the metatags field will store as

metatags
- basic
  - title
    - #text: field contents
    - #translation
      - #text: translated field contents

This is all verified on a clean install of core with only tmgmt, tmgmt_content, tmgmt_file, and metatags installed.

I'm including a patch that pushes all the metatag data into an initial index/delta of 0.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Source: Entity

Created by

πŸ‡ΊπŸ‡ΈUnited States markhuot

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024