php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72508 strange references after recursive function call and "switch" statement
Submitted: 2016-06-28 05:58 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: aleksander dot vladishev at zabbix dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.8 OS: ubuntu-16.04-server-amd64
Private report: No CVE-ID: None
 [2016-06-28 05:58 UTC] aleksander dot vladishev at zabbix dot com
Description:
------------
This regression was introduced in 7.0.x, and worked perfectly otherwise in previous versions (5.6.x).

It can be reproduced with "default:" case only.

Test script:
---------------
<?php
function check_data(&$var) {
        if (is_array($var)) {
                foreach ($var as $key => $val) {
                        check_data($var[$key]);
                }
        }
}

$data = ['values' => [['type' => '4']]];
check_data($data);
$values = $data['values'];
foreach ($values as &$value) {
        switch ($value['type']) {
                default:
                        $value['value'] = true;
        }
}
unset($value);
echo var_dump($values)."\n".var_dump($data)."\n";

Expected result:
----------------
array(1) {
  [0]=>
  array(2) {
    ["type"]=>
    string(1) "4"
    ["value"]=>
    bool(true)
  }
}
array(1) {
  ["values"]=>
  array(1) {
    [0]=>
    array(1) {
      ["type"]=>
      string(1) "4"
    }
  }
}


Actual result:
--------------
array(1) {
  [0]=>
  array(2) {
    ["type"]=>
    &string(1) "4"
    ["value"]=>
    bool(true)
  }
}
array(1) {
  ["values"]=>
  array(1) {
    [0]=>
    array(1) {
      ["type"]=>
      &string(1) "4"
    }
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-28 07:37 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ce7e180a04009e821c87e7ae2b704294a2a97c03
Log: Fixed bug #72508 (strange references after recursive function call and &quot;switch&quot; statement)
 [2016-06-28 07:37 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-07-06 05:47 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ce7e180a04009e821c87e7ae2b704294a2a97c03
Log: Fixed bug #72508 (strange references after recursive function call and &quot;switch&quot; statement)
 [2016-07-20 11:30 UTC] davey@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ce7e180a04009e821c87e7ae2b704294a2a97c03
Log: Fixed bug #72508 (strange references after recursive function call and &quot;switch&quot; statement)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC