From ea0229dcfc1a47166c47e550e01f1f8b07cae08d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 10 Oct 2025 22:22:39 +0200 Subject: [PATCH] Return with error code if precompile_smarty fails The Smarty API for compiling templates don't return any meaningful error status if a template fails, so we buffer the output and scan it for error messages instead. If we find one, we return a non-zero error code to signal the error to the shell or calling process. Also added more detailed copyright headers. --- util/precompile_smarty3.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/util/precompile_smarty3.php b/util/precompile_smarty3.php index 4ae926525..ead62fecf 100755 --- a/util/precompile_smarty3.php +++ b/util/precompile_smarty3.php @@ -1,8 +1,13 @@ + * SPDX-FileContributor: Mario + * SPDX-FileContributor: Harald Eilertsen + * + * SPDX-License-Identifier: MIT + */ require_once dirname(__DIR__) . '/boot.php'; @@ -16,7 +21,16 @@ $s->setCompileDir(TEMPLATE_BUILD_PATH . '/compiled/'); $s->setConfigDir(TEMPLATE_BUILD_PATH . '/config/'); $s->setCacheDir(TEMPLATE_BUILD_PATH . '/cache/'); -$s->left_delimiter = '{{'; -$s->right_delimiter = '}}'; +$s->setLeftDelimiter('{{'); +$s->setRightDelimiter('}}'); +// Capture the output... +ob_start(); $s->compileAllTemplates('.tpl', true); +$buf = ob_get_flush(); + +// ...so that we can check if there was any errors +if (strpos($buf, '------>Error: ') !== false) { + // Signal to the shell if there was + exit(-1); +}