bug #4947 Stop looking up a macro twice in its own namespace when it is declared by a parent (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Stop looking up a macro twice in its own namespace when it is declared by a parent

Commits
-------

e3f0d6fb4c Stop looking up a macro twice in its own namespace when it is declared by a parent
This commit is contained in:
Fabien Potencier
2026-09-25 15:50:23 +02:00
+1 -1
View File
@@ -57,7 +57,7 @@ final class MacroNamespace
return $macro->callLegacy($arguments, $source, $line);
}
if (null === $macro = $this->resolve($name, $context)) {
if (null === $macro = $this->getParent($context)?->resolve($name, $context)) {
if (!str_starts_with($name, 'macro_') || null === $macro = $this->resolve($bareName = substr($name, \strlen('macro_')), $context)) {
throw new RuntimeError(\sprintf('Macro "%s" is not defined in template "%s".', $name, $this->template->getTemplateName()), $line, $source);
}