From cdba9dca8a6a308a7a60471490e77f70a33ed189 Mon Sep 17 00:00:00 2001 From: mohrt Date: Fri, 12 Jul 2002 15:20:15 +0000 Subject: [PATCH] fix append function with array/string issue --- Smarty.class.php | 14 ++++++++++---- libs/Smarty.class.php | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Smarty.class.php b/Smarty.class.php index b23e3b5f..63281f64 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -246,13 +246,19 @@ class Smarty { if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { - if (!empty($key)) { - (array)$this->_tpl_vars[$key][] = $val; + if ($key != '') { + if(!is_array($this->_tpl_vars[$key])) { + settype($this->_tpl_vars[$key],'array'); + } + $this->_tpl_vars[$key][] = $val; } } } else { - if (!empty($tpl_var) && isset($value)) { - (array)$this->_tpl_vars[$tpl_var][] = $value; + if ($tpl_var != '' && isset($value)) { + if(!is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + $this->_tpl_vars[$tpl_var][] = $value; } } $this->_extract = true; diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index b23e3b5f..63281f64 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -246,13 +246,19 @@ class Smarty { if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { - if (!empty($key)) { - (array)$this->_tpl_vars[$key][] = $val; + if ($key != '') { + if(!is_array($this->_tpl_vars[$key])) { + settype($this->_tpl_vars[$key],'array'); + } + $this->_tpl_vars[$key][] = $val; } } } else { - if (!empty($tpl_var) && isset($value)) { - (array)$this->_tpl_vars[$tpl_var][] = $value; + if ($tpl_var != '' && isset($value)) { + if(!is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + $this->_tpl_vars[$tpl_var][] = $value; } } $this->_extract = true;