temp fix for static smarty during tests
authordemeritcowboy <demeritcowboy@hotmail.com>
Fri, 12 Nov 2021 14:54:38 +0000 (09:54 -0500)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Fri, 12 Nov 2021 16:47:39 +0000 (11:47 -0500)
CRM/Core/Form.php
CRM/Core/Page.php

index 4d82cc4a0a62c6050afe3d0da2a4c65bac0e0010..c61a92992f3ab1a1159d48e70e871e7373858e72 100644 (file)
@@ -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));
 
index 7404125fc8fae5d8fa08758a8b04e4890d1716e3..e26d7407404fc1082130cbefe4da8d6e2cd98503 100644 (file)
@@ -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'])) {