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: 2017-10-24 05:45 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: laruence@php.net Assigned: bukka (profile)
Status: Assigned Package: JSON related
PHP Version: 7.0.6 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Jun 21 10:01:55 2018 UTC