From: Eileen McNaughton Date: Tue, 28 Jun 2022 05:43:52 +0000 (+1200) Subject: Reset smarty-security after an exception X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=95649f7c98ae3c384553f9958ebaf9caa03eb4a6;p=civicrm-core.git Reset smarty-security after an exception This stops tests from getting befuddled --- diff --git a/CRM/Core/Smarty.php b/CRM/Core/Smarty.php index c7476e9b94..483ef374ba 100644 --- a/CRM/Core/Smarty.php +++ b/CRM/Core/Smarty.php @@ -176,15 +176,22 @@ class CRM_Core_Smarty extends Smarty { * @param bool $display * * @return bool|mixed|string + * + * @noinspection PhpDocMissingThrowsInspection + * @noinspection PhpUnhandledExceptionInspection */ public function fetch($resource_name, $cache_id = NULL, $compile_id = NULL, $display = FALSE) { if (preg_match('/^(\s+)?string:/', $resource_name)) { $old_security = $this->security; $this->security = TRUE; } - $output = parent::fetch($resource_name, $cache_id, $compile_id, $display); - if (isset($old_security)) { - $this->security = $old_security; + try { + $output = parent::fetch($resource_name, $cache_id, $compile_id, $display); + } + finally { + if (isset($old_security)) { + $this->security = $old_security; + } } return $output; }