prevent an infinite loop when normalizing Link field value#18371
Merged
brandonkelly merged 4 commits into5.xfrom Feb 3, 2026
Merged
prevent an infinite loop when normalizing Link field value#18371brandonkelly merged 4 commits into5.xfrom
brandonkelly merged 4 commits into5.xfrom
Conversation
…lization over and over
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
It’s possible to trigger an infinite loop when adding content to a Link field nested in a matrix field.
If you have a setup like the one described in the “steps to reproduce” section below, when you add a nested entry with a link field and fill in its content, we’ll try to normalise the Link field value. At this point, the nested entry is fresh, which means we're supposed to propagate its content.
To check whether we should localise a link to an element, we get the translation key for the element in the site we’re propagating to and from.
Because the translation method is set to custom and the translation key uses a template, we end up calling
View::renderObjectTemplate().Because the translation key template contains
include(), we end up calling$object->toArray()using all the fields, and that will end up callingLink::normalizeValue(), which will try to get the translation key again, causing an infinite loop where the Link field value is never normalised.It was introduced by this change: c3efaec.
Steps to reproduce:
en, and a second one with the language set toen-GBgh18363-translation.twigwith the following code in it:{{ object.site.language[0:2] }}link18363) with all default settings and a translation method set to custom and translation key set to:{include('gh18363-translation.twig')}; (I also changed the order of the link types so that URL is first, as it makes it easier/quicker to test at the beginning)matrix18363) with an entry type (withLink) that contains only the Link field from the previous step, propagation method set to custom, propagation key format set to{include('gh18363-translation.twig')}and view mode: blocksgh18363) with all default settings (can have revisions, enabled for both sites, propagation: all, etc), with an entry type (et18363) that contains the Title field and the Matrix field from the previous stepAdditional notes:
Temporary workaround:
Instead of using
{include('gh18363-translation.twig')}as the translation key for the Link field, use the content of that template directly:{{object.site.language[0:2]}}.Related issues
#18363