return parent::addTemplateDir($template_dir, $key, $isConfig);
}
if (is_array($this->template_dir)) {
- array_unshift($this->template_dir, $template_dir);
+ if (!in_array($template_dir, $this->template_dir)) {
+ array_unshift($this->template_dir, $template_dir);
+ }
}
else {
$this->template_dir = [$template_dir, $this->template_dir];
* Auto-register "templates/" folder.
*
* @mixinName smarty-v2
- * @mixinVersion 1.0.0
+ * @mixinVersion 1.0.1
* @since 5.59
*
* @param CRM_Extension_MixInfo $mixInfo
}
$register = function() use ($dir) {
- // This implementation is useful for older versions of CiviCRM. It can be replaced/updated going forward (v1.1+).
- $smarty = CRM_Core_Smarty::singleton();
- if (!is_array($smarty->template_dir)) {
- $this->template_dir = [$smarty->template_dir];
- }
- if (!in_array($dir, $smarty->template_dir)) {
- array_unshift($smarty->template_dir, $dir);
- }
+ // This implementation has a theoretical edge-case bug on older versions of CiviCRM where a template could
+ // be registered more than once.
+ CRM_Core_Smarty::singleton()->addTemplateDir($dir);
};
// Let's figure out what environment we're in -- so that we know the best way to call $register().