Skip to content

Commit

Permalink
Max out smarty grumpiness
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jan 17, 2022
1 parent 7fa8c8f commit 7f795c9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CRM/Core/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private function initialize() {
}

$this->register_function('crmURL', ['CRM_Utils_System', 'crmURL']);
if (CRM_Utils_Constant::value('CIVICRM_SMARTY_DEFAULT_ESCAPE')) {
if (CRM_Utils_Constant::value('CIVICRM_SMARTY_DEFAULT_ESCAPE') || self::isTestEnvironment()) {
// When default escape is enabled if the core escape is called before
// any custom escaping is done the modifier_escape function is not
// found, so require_once straight away. Note this was hit on the basic
Expand All @@ -158,6 +158,17 @@ private function initialize() {
}
}

/**
* Is this a test environment.
*
* Currently we just check the class name but it is possible to run tests in CMS frameworks.
*
* @return bool
*/
private static function isTestEnvironment(): bool {
return CRM_Core_Config::singleton()->userFramework === 'UnitTests';
}

/**
* Static instance provider.
*
Expand Down

0 comments on commit 7f795c9

Please sign in to comment.