From 1665005fb71551fd4b5f3841ea46912e0fb31bd8 Mon Sep 17 00:00:00 2001 From: Alex Schickedanz Date: Sat, 27 Dec 2025 00:20:51 +0100 Subject: [PATCH] Fix compileAll() behavior. compileAll() has two issues that get fixed with this commit: 1. `$force_compile` is ignored since it is applied to a cloned instance of Smarty that then is not used. 2. The `$max_errors` variable behaves strange as the function stops executing as soon $max_errors is reached. However, the name suggests that `$max_errors` is the maximum number of acceptable errors (defaults to `null` meaning unlimited). When called with `$max_errors = 0`, the function compiles only the first template and then stops with "too many errors" and a total error count of zero. --- src/Smarty.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Smarty.php b/src/Smarty.php index b53a36c20..e6132f5a2 100644 --- a/src/Smarty.php +++ b/src/Smarty.php @@ -1487,7 +1487,7 @@ protected function compileAll( // $_smarty->force_compile = $force_compile; try { - $_tpl = $this->doCreateTemplate($_file); + $_tpl = $_smarty->doCreateTemplate($_file); $_tpl->caching = self::CACHING_OFF; $_tpl->setSource( $isConfig ? \Smarty\Template\Config::load($_tpl) : \Smarty\Template\Source::load($_tpl) @@ -1507,7 +1507,7 @@ protected function compileAll( } // free memory unset($_tpl); - if ($max_errors !== null && $_error_count === $max_errors) { + if ($max_errors !== null && $_error_count > $max_errors) { echo "\ntoo many errors\n"; exit(1); }