Metatag changed storage format

Created on 24 October 2023, 8 months ago

Problem/Motivation

There is an error with pagedesigner_yoast if metatag:2.x is used:

Notice: unserialize(): Error at offset 0 of 122 bytes in Drupal\pagedesigner_yoast\Plugin\Field\FieldFormatter\DescriptionFormatter->viewElements() (line 29 of modules/contrib/pagedesigner/modules/pagedesigner_yoast/src/Plugin/Field/FieldFormatter/DescriptionFormatter.php).
Drupal\pagedesigner_yoast\Plugin\Field\FieldFormatter\DescriptionFormatter->viewElements(Object, 'en') (Line: 89)
Drupal\Core\Field\FormatterBase->view(Object, 'en') (Line: 265)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 256)
Drupal\views\Entity\Render\EntityFieldRenderer->buildFields(Array) (Line: 143)
Drupal\views\Entity\Render\EntityFieldRenderer->render(Object, Object) (Line: 833)
Drupal\views\Plugin\views\field\EntityField->getItems(Object) (Line: 1151)
Drupal\views\Plugin\views\field\FieldPluginBase->advancedRender(Object) (Line: 238)

This is caused by the stored data now being JSON instead of serialized arrays.

Steps to reproduce

1. Install drupal/metatag:^1.0
2. Install pagedesigner_yoast, add yoast_seo field to a node and add some data.
3. Use the "pagedesigner_yoast_metatag_description" formatter on the yoast_seo description field in a view. The view renders normally.
3. Upgrade to drupal/metatag:^2.0, run update scripts.
4. The view renders no more description and produces the error above.

Proposed resolution

drupal/yoast_seo:^1.0 || ^2.0 do not specify the version of metatag to use.
So, we need to allow both formats, using unserialize and Json::decode.

Remaining tasks

- Implement a check on the data provided and unmarshall it accordingly.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland pvbergen

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

Comments & Activities

Production build 0.69.0 2024