Merge pull request #22610 from colemanw/deprecatedUnusedFunction
[civicrm-core.git] / CRM / Core / Smarty.php
index 32d21372d4a0fb0c856dc5a90da0bd37df7208d0..bcd9c69d91bddd7e9aa8cce5f5d4d1e6f94c0805 100644 (file)
@@ -63,15 +63,6 @@ class CRM_Core_Smarty extends Smarty {
    */
   private $backupFrames = [];
 
-  /**
-   * Class constructor.
-   *
-   * @return CRM_Core_Smarty
-   */
-  public function __construct() {
-    parent::__construct();
-  }
-
   private function initialize() {
     $config = CRM_Core_Config::singleton();
 
@@ -139,6 +130,11 @@ class CRM_Core_Smarty extends Smarty {
 
     $this->register_function('crmURL', ['CRM_Utils_System', 'crmURL']);
     if (CRM_Utils_Constant::value('CIVICRM_SMARTY_DEFAULT_ESCAPE')) {
+      // 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
+      // contribution dashboard from RecentlyViewed.tpl
+      require_once 'Smarty/plugins/modifier.escape.php';
       if (!isset($this->_plugins['modifier']['escape'])) {
         $this->register_modifier('escape', ['CRM_Core_Smarty', 'escape']);
       }
@@ -390,7 +386,7 @@ class CRM_Core_Smarty extends Smarty {
    *
    * @return string
    */
-  public static function escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1') {
+  public static function escape($string, $esc_type = 'html', $char_set = 'UTF-8') {
     // CiviCRM variables are often arrays - just handle them.
     // The early return on booleans & numbers is mostly to prevent them being
     // logged as 'changed' when they are cast to a string.
@@ -429,7 +425,7 @@ class CRM_Core_Smarty extends Smarty {
         return $string;
       }
     }
-    require_once 'Smarty/plugins/modifier.escape.php';
+
     $value = smarty_modifier_escape($string, $esc_type, $char_set);
     if ($value !== $string) {
       Civi::log()->debug('smarty escaping original {original}, escaped {escaped} type {type} charset {charset}', [