php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73847 Recursion when a variable is redefined as array
Submitted: 2016-12-31 07:28 UTC Modified: 2016-12-31 12:16 UTC
From: joyce at ennexa dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 7.1.0 OS:
Private report: No CVE-ID: None
 [2016-12-31 07:28 UTC] joyce at ennexa dot com
Description:
------------
Redefining a variable as an array with the old value as  member causes recursion.

Test script:
---------------
<?php
$a = 23;
$a = array($a);
print_r($a);


Expected result:
----------------
Array
(
    [0] => 23
)

Actual result:
--------------
Array
(
    [0] => Array
 *RECURSION*
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-31 12:04 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2016-12-31 12:04 UTC] cmb@php.net
I can't reproduce that: <https://3v4l.org/6p5r1>.

Please specify the exact version of PHP you're using, which
zend_extensions are enabled, and your OS.
 [2016-12-31 12:16 UTC] nikic@php.net
-Status: Feedback +Status: Verified -Assigned To: cmb +Assigned To:
 [2016-12-31 12:16 UTC] nikic@php.net
It's an opcache optimizer problem. Wrap it in a function to reproduce:

<?php
function test() {
    $a = 23;
    $a = array($a);
    print_r($a);
}
test();
 [2016-12-31 12:34 UTC] nikic@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=242d924e599d2c92a5d12873ad1564f7d44f7126
Log: Fix bug #73847
 [2016-12-31 12:34 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC