浏览代码

Fix every value of a model was casted to string by getter method

ohartl 9 年之前
父节点
当前提交
23f1cd5b06
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      include/php/models/AbstractModel.php

+ 8 - 4
include/php/models/AbstractModel.php

@@ -234,12 +234,16 @@ abstract class AbstractModel
 	public function getAttribute($attribute)
 	public function getAttribute($attribute)
 	{
 	{
 		if(isset($this->data[$attribute])){
 		if(isset($this->data[$attribute])){
-			if(is_array($this->data[$attribute])){
-				return array_map('strip_tags', $this->data[$attribute]);
+			$value = $this->data[$attribute];
+
+			if(is_array($value)){
+				return array_map('strip_tags', $value);
 			}
 			}
-			else{
-				return strip_tags($this->data[$attribute]);
+			elseif(is_string($value)){
+				return strip_tags($value);
 			}
 			}
+
+			return $value;
 		}
 		}
 
 
 		return null;
 		return null;