Problem/Motivation

When running external_hreflang 2.0.4 with metatag 2.2.1 the following error occurs:

PHP Fatal error: Declaration of Drupal\external_hreflang\Plugin\metatag\Tag\ExternalHreflang::description(): Drupal\Core\StringTranslation\TranslatableMarkup|string must be compatible with Drupal\metatag\Plugin\metatag\Tag\MetaNameBase::description(): ?Drupal\Core\StringTranslation\TranslatableMarkup in web/modules/contrib/external_hreflang/src/Plugin/metatag/Tag/ExternalHreflang.php on line 83

Potentially 2.2.1 breaks other modules that extend MetaNameBase class.

Steps to reproduce

  1. Install external_hreflang version 2.0.4
  2. Make sure that metatag module version is 2.2.1

Proposed resolution

Widen the scope to keep subclasses valid

public function description(): TranslatableMarkup|string|null {

Change the declaration in next major version.

Remaining tasks

Create MR, check other changed plugin declarations.

User interface changes

None

API changes

None

Data model changes

None

Issue fork metatag-3632998

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

a.dmitriiev created an issue. See original summary.

a.dmitriiev’s picture

Issue summary: View changes
a.dmitriiev’s picture

Issue summary: View changes

a.dmitriiev’s picture

Status: Active » Needs review

I have created MR that reverts and adjusts the typehints for label and description methods to still be backwards compatible, as patch version of the module should be. I haven't checked other places as commit https://git.drupalcode.org/project/metatag/-/commit/989fa387d08975276fbe... is huge.

I see that for GroupBase the same change only was done in php doc block, not in the typehint https://git.drupalcode.org/project/metatag/-/commit/989fa387d08975276fbe...

It looks like no other base class is affected with changes from #3398796: Add PHP attributes for all plugins

f0ns made their first commit to this issue’s fork.

f0ns’s picture

Just had a look and it looks good.

I found a small fix while checking this out, but it's better as a follow-up. I pushed it here by mistake and reverted it, so the MR is back to the original change.

The fix is now in #3633005: Meta tag and group descriptions are empty since 2.2.1.

f0ns’s picture

Status: Needs review » Reviewed & tested by the community
damienmckenna’s picture

Thank you for the bug report, I'm sorry that bug slipped in, though I'm surprised it wasn't caught by the test coverage :-\

Anyways, thank you, I'll include this is in a hotfix release this morning.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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