浏览代码

Dont decode twice.

Mark Scherer 9 年之前
父节点
当前提交
351a1798a4
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/Model/Behavior/JsonableBehavior.php

+ 5 - 1
src/Model/Behavior/JsonableBehavior.php

@@ -18,7 +18,7 @@ use Tools\Utility\Text;
  *
  * This is a port of the Serializeable behavior by Matsimitsu (http://www.matsimitsu.nl)
  * Modified by Mark Scherer (http://www.dereuromark.de)
- *
+ *s
  * Supports different input/output formats:
  * - "list" is useful as some kind of pseudo enums or simple lists
  * - "params" is useful for multiple key/value pairs
@@ -216,6 +216,10 @@ class JsonableBehavior extends Behavior {
 	 * @return mixed
 	 */
 	public function _decode($val) {
+		if (!is_string($val)) {
+			return $val;
+		}
+
 		$decoded = json_decode($val, $this->_config['decodeParams']['assoc'], $this->_config['decodeParams']['depth'], $this->_config['decodeParams']['options']);
 
 		if ($decoded === false) {