shorthand_metatags_alter hook doesn't work with non-fieldable entities

Created on 23 February 2023, over 1 year ago
Updated 24 November 2023, 12 months ago

Problem/Motivation

The recent change to resolve issue 3274488 doesn't seem to work with non-fieldable entities such as Webforms.

When installing the Shorthand module on a site using Webform, we encountered the following error:

Error: Call to undefined method Drupal\webform\Entity\Webform::getFieldDefinitions() in shorthand_metatags_alter() (line 116 of modules/contrib/shorthand/shorthand.module).

Proposed resolution

Adding an additional condition on line 116 to check whether the entity implements FieldableEntityInterface seems to fix. (Approach borrowed from this fix , found while researching the issue.)

A patch containing this change is attached.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇬🇧United Kingdom ian-dcuk

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

Comments & Activities

Production build 0.71.5 2024