Updates CoreExtension::twig_constant to check for definition first to avoid hard crash

This commit is contained in:
Alex Henderson-Roche
2022-11-08 18:11:59 +02:00
committed by Fabien Potencier
parent 0986e54682
commit 56b31224bd
+4
View File
@@ -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);
}