From 4ab7be1f1191fe92efc56843e26e6abc5561f2c3 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Fri, 12 Nov 2021 09:54:38 -0500 Subject: [PATCH] temp fix for static smarty during tests --- CRM/Core/Form.php | 7 ++++++- CRM/Core/Page.php | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 4d82cc4a0a..c61a92992f 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -321,8 +321,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); - self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); } + // Smarty $_template is a static var which persists between tests, so + // if something calls clearTemplateVars(), the static still exists but + // our ensured variables get blown away, so we need to set them even if + // it's already been initialized. + self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); + // Workaround for CRM-15153 - give each form a reasonably unique css class $this->addClass(CRM_Utils_System::getClassName($this)); diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index 7404125fc8..e26d740740 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -139,8 +139,12 @@ class CRM_Core_Page { if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); self::$_session = CRM_Core_Session::singleton(); - self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); } + // Smarty $_template is a static var which persists between tests, so + // if something calls clearTemplateVars(), the static still exists but + // our ensured variables get blown away, so we need to set them even if + // it's already been initialized. + self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); // FIXME - why are we messing with 'snippet'? Why not just pass it directly into $this->_print? if (!empty($_REQUEST['snippet'])) { -- 2.25.1