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.

CommentFileSizeAuthor
check_for_fieldableentityinterface.patch628 bytesian-dcuk

Comments

ian-dcuk created an issue. See original summary.

vladimiraus’s picture

Status: Active » Needs review
robcarr’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch - resolved the problem (below) for me, although I was using latest release - so line numbering different - and my error was based on Views [another non-fieldable entity]

Error: Call to undefined method Drupal\views\Entity\View::getFieldDefinitions() in shorthand_metatags_alter() (line 114 of modules/contrib/shorthand/shorthand.module).

vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thank you! Commited! Cheers! 🍺

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.