zend-json icon indicating copy to clipboard operation
zend-json copied to clipboard

Zend\Json\Json::decode null or empty string throw Zend\Json\Exception\RuntimeException on PHP7

Open yuripave opened this issue 9 years ago • 4 comments

Similar to https://github.com/zendframework/zf1/issues/678. ZF1 fix PR on https://github.com/zendframework/zf1/pull/680.

yuripave avatar Apr 14 '16 15:04 yuripave

As already told in zendframework/zend-cache#95

  • It's a bug in zend-cache that will be addressed by zendframework/zend-cache#96
  • In my opinion a serializer (all of zend-serializer and zend-json) should throw an exception in case of trying to unserialize or decode invalid input

marc-mabe avatar Apr 15 '16 19:04 marc-mabe

Agree as a serializer component we should throw an exception in case of trying to unserialize or decode invalid input. Those that upgrading PHP5 to PHP7 will need to deal with json_last_error behavior change such that json_decode('') PHP5 return JSON_ERROR_NONE but PHP7 return JSON_ERROR_SYNTAX.

References: https://bugs.php.net/bug.php?id=71718 http://php.net/manual/en/function.json-last-error.php#118165 http://stackoverflow.com/questions/36362856/php7-json-and-zend-decoding-failed-syntax-error

yuripave avatar Apr 16 '16 05:04 yuripave

Php changed behavior of json_last_error with major version changing. Component zend-json doesn't change major or even minor version. In my opinion, it must preserve backward compatibility and fix issue on php7. Anyway, component should have the same behaviour on all supported versions of php.

v-noskov avatar Apr 16 '16 07:04 v-noskov

This repository has been closed and moved to laminas/laminas-json; a new issue has been opened at https://github.com/laminas/laminas-json/issues/6.

weierophinney avatar Dec 31 '19 21:12 weierophinney