Просмотр исходного кода

Update Json.php

Catch exception and rethrow instead of testing on null.
Siad Ardroumli 12 лет назад
Родитель
Сommit
1918847e3a
1 измененных файлов с 3 добавлено и 6 удалено
  1. 3 6
      library/Zend/Serializer/Adapter/Json.php

+ 3 - 6
library/Zend/Serializer/Adapter/Json.php

@@ -77,17 +77,14 @@ class Zend_Serializer_Adapter_Json extends Zend_Serializer_Adapter_AdapterAbstra
 
         try {
             $ret = Zend_Json::decode($json, $opts['objectDecodeType']);
+        } catch (Zend_Json_Exception $e) {
+            require_once 'Zend/Serializer/Exception.php';
+            throw new Zend_Serializer_Exception('Invalid json data');
         } catch (Exception $e) {
             require_once 'Zend/Serializer/Exception.php';
             throw new Zend_Serializer_Exception('Unserialization failed by previous error', 0, $e);
         }
 
-        // json_decode returns null for invalid JSON
-        if ($ret === null && $json !== 'null') {
-            require_once 'Zend/Serializer/Exception.php';
-            throw new Zend_Serializer_Exception('Invalid json data');
-        }
-
         return $ret;
     }
 }