[ticket/15214] Move if statement to a better place

Putting this here will have the loop run the same amount of times as default.
Without this, the loop runs too many extra times.

PHPBB3-15214
This commit is contained in:
toxyy 2023-12-09 13:19:13 -05:00
parent 1e2532a9a9
commit 648cd688ca

View file

@ -50,18 +50,19 @@ class event extends \Twig\Node\Node
// Group and sort extension template events in according to their priority (0 by default if not set)
foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path)
{
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
$ext_namespace = str_replace('/', '_', $ext_namespace);
$priority_key = $this->template_event_priority_array[$ext_namespace][$location] ?? 0;
$template_events[$priority_key][] = $ext_namespace;
}
}
krsort($template_events);
foreach ($template_events as $events)
{
foreach ($events as $ext_namespace)
{
if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
{
if ($this->environment->isDebug())
{
@ -92,4 +93,3 @@ class event extends \Twig\Node\Node
}
}
}
}