php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72170 JsonSerializable may inc apply count without dec it
Submitted: 2016-05-06 10:30 UTC Modified: 2021-04-20 12:39 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: laruence@php.net Assigned: bukka (profile)
Status: Closed Package: JSON related
PHP Version: 7.0.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: laruence@php.net
New email:
PHP Version: OS:

 

 [2016-05-06 10:30 UTC] laruence@php.net
Description:
------------
see test script

Test script:
---------------
<?php

class Dummy implements JsonSerializable{
    public function jsonSerialize() {
        global $flag;
        if ($flag) {
            exit;
        } else {
            return "xxxx";
        }
    }
}

$array = array(new Dummy());
$array[] = "xxx";

register_shutdown_function(function() use($array) {
    global $flag;
    $flag = 0;
    var_dump(json_encode(array($array)));
});

$flag = 1;
var_dump(json_encode(array($array)));

Expected result:
----------------
string(16) "[["xxxx","xxx"]]"

Actual result:
--------------
false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-06 10:46 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=459a7cc209da130256d66c1f896199540f4dadbc
Log: Fixed bug #72170 (JsonSerializable may inc apply count without dec it)
 [2016-05-06 10:46 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-05-06 10:48 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=459a7cc209da130256d66c1f896199540f4dadbc
Log: Fixed bug #72170 (JsonSerializable may inc apply count without dec it)
 [2016-05-06 12:25 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=197470b62f8256898adfe758302cb0241195c480
Log: Revert &quot;Fixed bug #72170 (JsonSerializable may inc apply count without dec it)&quot;
 [2016-05-06 12:26 UTC] laruence@php.net
-Status: Closed +Status: Re-Opened -Assigned To: +Assigned To: bukka
 [2016-05-15 15:07 UTC] bukka@php.net
-Package: json +Package: JSON related
 [2016-07-20 11:31 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=197470b62f8256898adfe758302cb0241195c480
Log: Revert &quot;Fixed bug #72170 (JsonSerializable may inc apply count without dec it)&quot;
 [2016-07-20 11:31 UTC] davey@php.net
-Status: Re-Opened +Status: Closed
 [2016-07-20 11:31 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=459a7cc209da130256d66c1f896199540f4dadbc
Log: Fixed bug #72170 (JsonSerializable may inc apply count without dec it)
 [2016-07-20 19:02 UTC] bukka@php.net
-Status: Closed +Status: Re-Opened
 [2017-10-24 05:45 UTC] kalle@php.net
-Status: Re-Opened +Status: Assigned
 [2021-04-20 12:39 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2021-04-20 12:39 UTC] cmb@php.net
This issue is fixed as of PHP 8.0.0[1], possibly due to commit
da0663a337[2].

[1] <https://3v4l.org/uSSZ6>
[2] <http://github.com/php/php-src/commit/da0663a337b608a4b0008672b494e3a71e6e4cfc>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 20:01:32 2024 UTC