[4.x] Antlers: Improves custom variable assignment inside tags #8818
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.
This PR improves an over-aggressive internal tag parameter check. This internal check looks for specific tag parameters that will modify the resulting scope in some way that causes the current renderer to be unable to handle the tag's results.
With the current over-aggressive check, the following simplified example:
would produce the following output:
The current check is over-aggressive since it will pass if the tag contains any parameter with the same name as an existing modifier. The refactored check will only pass if the tag has any of the following parameter names:
The
AntlersNode
retains the existinghasModifierParameters
method, even though internal use has been discontinued, because it's a public method and third-party code might be using it for template analysis.For performance reasons, the
AntlersNodeParser
now directly conducts the new check and sets a public property on the node. This change helps avoid array lookups and additional method calls in a hot code path.Note: this check exists to help decide if the runtime's current
NodeProcessor
instance can handle the tag's results instead of relying on theAntlersLoop
class orparseLoop
method on the tag instance. Both have severe performance implications with the runtime and reusing the node processor as much as possible is always preferred. However, things get complicated with the above list of tag parameters, where a new copy of the current scope is required to prevent unintended side effects.The current behavior happens because the runtime cannot accurately detect/trace what is happening inside the
AntlersLoop
class or theparseLoop
methods. A workaround for this behavior is to simply alias the results: