ID:               31942
 Comment by:       kevin at planetsaphire dot com
 Reported By:      adrian-phpbugs at sixfingeredman dot net
 Status:           No Feedback
 Bug Type:         Arrays related
 Operating System: Linux
 PHP Version:      4.3.11-dev
 New Comment:

My intranet project appears to be having problems due to this bug.  I
am running PHP Version 5.1.2.  I noticed that this bug was originally
filed against PHP 4.3.11, and can file a seperate report if I need to.

The phpinfo file on my server:

http://www.planetsaphire.com/phpinfo.php

On wwwbiz, if I have an inventory category three leaves or more deep,
it will not be matched to a higher leaf, which causes the script to
call my error_dbdown() function.  This is being caused by the foreach()
syntax, and it happens regardless if I use the reference operator or
not.

Sources can be viewed from:
http://www.planetsaphire.com/viewcvs.cgi
cvs -d:pserver:[EMAIL PROTECTED]:/cvsroot/www co -P
wwwbiz

File possibly affected by this bug is: db/mysql-inv.php


Previous Comments:
------------------------------------------------------------------------

[2005-09-10 01:00:05] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2005-09-02 07:46:02] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-02-12 00:22:04] adrian-phpbugs at sixfingeredman dot net

The version says: (built: Jan  5 2005 08:54:18)

------------------------------------------------------------------------

[2005-02-12 00:19:59] adrian-phpbugs at sixfingeredman dot net

Description:
------------
This might be related to #5052. The code below illustrates the problem
pretty well -- the class method should be returning a fresh copy of the
field but in fact the return value is sharing the foreach-counter so
that nested foreaches break. If I do something to force a copy, like
"$foo->_member =& $foo->_member" (I have no idea *why* this forces a
copy), then it works.

Reproduce code:
---------------
<?
class foo {
        var $_member = array(1, 2, 3);
        function member() {
                return $this->_member;
        }
}
$foo = new foo();
#$foo->_member =& $foo->_member;

$size = 0;
foreach ($foo->member() as $v) {
        $size++;
        foreach ($foo->member() as $v) {}
}
if ($size < count($foo->member())) die("BUG FOUND");


Expected result:
----------------
I expect $size == count($foo->member()). If you uncomment the commented
line, it works.

Actual result:
--------------
The inner foreach iterates through every value, but the outer foreach
only iterates through the first value.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31942&edit=1

Reply via email to