Upgrade from metatag v1 to v2 causes recursion/infinite loop error on drupal 10.5

Created on 21 July 2025, about 1 month ago

The website encountered an unexpected error. Try again later.

Error: Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? in Drupal\Core\Entity\ContentEntityBase->Drupal\Core\Entity\{closure}() (line 1042 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).

array_filter() (Line: 1041)
Drupal\Core\Entity\ContentEntityBase->getTranslationLanguages() (Line: 97)
Drupal\Core\Entity\EntityRepository->getTranslationFromContext() (Line: 1735)
_field_tokens() (Line: 503)
token_tokens()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 364)
Drupal\Core\Utility\Token->generate() (Line: 1097)
token_tokens()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 364)
Drupal\Core\Utility\Token->generate() (Line: 241)
Drupal\Core\Utility\Token->doReplace() (Line: 191)
Drupal\Core\Utility\Token->replace() (Line: 152)
Drupal\webform\WebformTokenManager->replace() (Line: 171)
Drupal\webform\WebformTokenManager->replaceNoRenderContext() (Line: 261)
Drupal\webform\Entity\WebformSubmission->label() (Line: 105)
Drupal\webform\Controller\WebformSubmissionViewController->title()
call_user_func_array() (Line: 58)
Drupal\Core\Controller\TitleResolver->getTitle() (Line: 880)
token_tokens()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 364)
Drupal\Core\Utility\Token->generate() (Line: 241)
Drupal\Core\Utility\Token->doReplace() (Line: 191)
Drupal\Core\Utility\Token->replace() (Line: 66)
Drupal\metatag\MetatagToken->replace() (Line: 791)
Drupal\metatag\MetatagManager->processTagValue() (Line: 634)
Drupal\metatag\MetatagManager->generateRawElements() (Line: 61)
Drupal\metatag\Plugin\Field\MetatagEntityFieldItemList::Drupal\metatag\Plugin\Field\{closure}() (Line: 637)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 48)
Drupal\metatag\Plugin\Field\MetatagEntityFieldItemList->computeValue() (Line: 32)
Drupal\metatag\Plugin\Field\MetatagEntityFieldItemList->ensureComputedValue() (Line: 43)
Drupal\metatag\Plugin\Field\MetatagEntityFieldItemList->getValue() (Line: 723)
Drupal\Core\Entity\ContentEntityBase->toArray() (Line: 950)

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇮🇳India pemson18 South Goa

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

Comments & Activities

  • Issue created by @pemson18
  • 🇺🇸United States wmcmillian-coalmarch

    I added a patch for this.

    The issue is that the tokens function pulls in all of the tags attached to an entity and then runs token replace on them. If any of the tags reference via token any other tag, this causes a recursion.

    This patch filters the tags being processed to only those being referenced by token and should ignore any tag value that references itself.

  • 🇺🇸United States damienmckenna NH, USA

    Do you have an example of a token that triggers the problem?

Production build 0.71.5 2024