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
- Install external_hreflang version 2.0.4
- 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
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
Comment #2
a.dmitriiev commentedComment #3
a.dmitriiev commentedComment #5
a.dmitriiev commentedI 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
Comment #7
f0ns commentedJust 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.
Comment #8
f0ns commentedComment #9
damienmckennaThank 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.
Comment #11
damienmckennaCommitted. Thank you.