php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66167 Incorrect result on list()
Submitted: 2013-11-25 14:34 UTC Modified: 2013-11-25 18:41 UTC
From: sander at prezent dot nl Assigned:
Status: Duplicate Package: Unknown/Other Function
PHP Version: 5.4.22 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
10 + 16 = ?
Subscribe to this entry?

 
 [2013-11-25 14:34 UTC] sander at prezent dot nl
Description:
------------
The attached test script seems not to work in PHP 5.4 and PHP 5.5:

On PHP 5.3 the output is (as I expect):

array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
}
string(3) "foo"
string(3) "bar"

On PHP 5.4 the output is (which is IMHO incorrect):

array(2) {
  [0] =>
  string(3) "foo"
  [1] =>
  string(3) "bar"
}
NULL
NULL

On PHP 5.5 the test code causes a SEGFAULT.

Exact PHP versions used:

On Debian Squeeze:

PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 13:13:26) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with XCache v1.3.0, Copyright (c) 2005-2009, by mOo
    with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

On Debian Wheezy:

PHP 5.4.21-1~dotdeb.1 (cli) (built: Nov  3 2013 06:56:41) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
    with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo

PHP 5.5.3-1~dotdeb.1 (cli) (built: Aug 29 2013 05:44:58) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans


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

class Test
{
    var $_foo = null;

    function Test()
    {
    }

    function run()
    {
        list($foo, $bar) = $this->_foo = $this->get();
        var_dump($this->_foo);
        var_dump($foo);
        var_dump($bar);
    }

    function get()
    {
        return array('foo', 'bar');
    }
}

$test = new Test();
$test->run();



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-25 18:36 UTC] requinix@php.net
My PHP 5.4.22 and 5.5.6 on Windows crashes, and 3v4l doesn't like it either.
http://3v4l.org/3bspc

Removing the assignment to $this->_foo makes it work again.
 [2013-11-25 18:41 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2013-11-25 18:41 UTC] nikic@php.net
Duplicate of https://bugs.php.net/bug.php?id=65969
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC