Doc #67469 [Asn->Csd]: json_encode changed behaviour in 5.5

From: Date: Fri, 28 Apr 2017 19:33:52 +0000
Subject: Doc #67469 [Asn->Csd]: json_encode changed behaviour in 5.5
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14658@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67469&edit=1 ID: 67469 Updated by: bukka@php.net Reported by: martin at ringehahn dot de Summary: json_encode changed behaviour in 5.5 -Status: Assigned +Status: Closed Type: Documentation Problem Package: JSON related PHP Version: 5.5.13 Assigned To: bukka Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2017-03-31 17:45:09] bukka@php.net Fix committed to docs: Revision: http://svn.php.net/viewvc/?view=revision&revision=342210 Log: Fix doc bug #67496 (json_encode changed behaviour in 5.5) P.S. Sorry for the wrong bug number in comment above (not 67496 but 67469...) ------------------------------------------------------------------------ [2014-06-20 12:55:26] martin at ringehahn dot de @arjen This is filed as a "Doc Bug" for a reason. Your link shows that between 5.4.29 http://3v4l.org/SIlJo#v536 (most recent 5.4) and 5.5.0 http://3v4l.org/SIlJo#v550this function has changed its behaviour. This has not been documented anywhere. Specifically: http://ca3.php.net/manual/en/migration55.changed-functions.php or http://ca3.php.net/manual/en/migration55.incompatible.php do not mention this change of behaviour. ------------------------------------------------------------------------ [2014-06-20 08:13:33] arjen at react dot com Your expected result was only the case for PHP 5.3.14, which was the result of not reverting a fix on time (see https://bugs.php.net/bug.php?id=61537) http://3v4l.org/SIlJo#v5314 Documentation could be updated, but the current behaviour seems fine to me. ------------------------------------------------------------------------ [2014-06-18 20:06:33] martin at ringehahn dot de Description: ------------ It appears that in 5.5, "#61537 json_encode() incorrectly truncates/discards information" has been addressed. php 5.4 and 5.3 also had this patch at some point but it was reverted later. I assume this was done for not breaking backcompat in point releases. However, the php 5.5 Changelog fails to mentioned that json_encode changed behaviour and now behaves as documented. specifically: "Returns a JSON encoded string on success or FALSE on failure." the documentation also fails to mention the new constant JSON_PARTIAL_OUTPUT_ON_ERROR. well, it actually mentions it by referencing to it but it is not listed as a proper item. Test script: --------------- echo json_encode(["foo" => chr(132), "bar" => "bar"]); // nothing, false // this used to return "Expected result" Expected result: ---------------- since the Changelog does not mention anything json-related, I'd expect the same behaviour as in previous versions: echo json_encode(["foo" => chr(132), "bar" => "bar"]); PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in php shell code on line 1 {"foo":null,"bar":"bar"} Actual result: -------------- false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67469&edit=1

« previous php.doc.bugs (#14658) next »