Skip to content

Commit

Permalink
Updates CoreExtension::twig_constant to check for definition first to…
Browse files Browse the repository at this point in the history
… avoid hard crash
  • Loading branch information
Alex Henderson-Roche authored and fabpot committed Dec 26, 2022
1 parent 0986e54 commit 56b3122
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Extension/CoreExtension.php
Expand Up @@ -1329,6 +1329,10 @@ function twig_constant($constant, $object = null)
$constant = \get_class($object).'::'.$constant;
}

if (!\defined($constant)) {
throw new RuntimeError(sprintf('Constant "%s" is undefined.', $constant));
}

return \constant($constant);
}

Expand Down

0 comments on commit 56b3122

Please sign in to comment.