#34752 [Opn->Fbk]: foreach seam to overwrite values
ID: 34752
Updated by: tony2001@php.net
Reported By: trash at jennyfm dot net
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: linux 2.6.13
PHP Version: 5.0.5
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-10-06 15:35:31] trash at jennyfm dot net
right....
this is my result.
http://wp1011644.wp021.webpack.hosteurope.de/muellercms/buii.php
------------------------------------------------------------------------
[2005-10-06 15:33:30] tony2001@php.net
"Returns wrong" ?
What's the expected result, what's the actual result you get?
This is what I got with 5.0.6-dev:
Array
(
[0] => Test Object
(
[blc:protected] =>
[bl:protected] =>
)
[1] => Test Object
(
[blc:protected] =>
[bl:protected] =>
)
)
Array
(
[0] => Test Object
(
[blc:protected] =>
[bl:protected] =>
)
[1] => Test Object
(
[blc:protected] =>
[bl:protected] =>
)
)
Is this "wrong" or "right" ?
------------------------------------------------------------------------
[2005-10-06 15:23:38] trash at jennyfm dot net
hmmpf ;D hope this is short enough
<?php
echo "<pre>";
class Test{
protected $blc;
protected $bl;
public function test2 (){
$this->bl['0'] =& new $this;
$this->bl['1'] =&new $this;
print_r($this->bl);
foreach ($this->bl as $key => $value){
$this->blc[$key] =true;
}
//here it returns wrong bl in 5.0.5, in <=5.0.4 it works fine
print_r($this->bl);
}
}
$buii = new Test();
$buii->test2();
echo "</pre>";
?>
------------------------------------------------------------------------
[2005-10-06 13:40:01] tony2001@php.net
I was asking about a SHORT reproduce script.
Those scripts are definitely not short.
All those classes and other stuff have nothing to do with foreach.
------------------------------------------------------------------------
[2005-10-06 13:35:39] trash at jennyfm dot net
The main script is here (with wrong result in php 5.0.5):
wp1011644.wp021.webpack.hosteurope.de/muellercms/test.php
source:
wp1011644.wp021.webpack.hosteurope.de/muellercms/test.php_
wp1011644.wp021.webpack.hosteurope.de/muellercms/include/function_template5.inc.php_
wp1011644.wp021.webpack.hosteurope.de/muellercms/include/function_templateext5.inc.php_
template file (not relevant):
wp1011644.wp021.webpack.hosteurope.de/muellercms/templates/test.tpl_
The error seems to be in function_templateext5::_initTemplate after the
foreach print_r($this->bl) returns overwritten result. In php 5.0.4 the
result looks like:
Array
(
[testsub] => PDTemplateExt Object
( [removeEmptyBlocks] => 1
[delimiterStart:protected] => {
[delimiterEnd:protected] => }
[t:protected] => )..........
test
buii
before the foreach the $test->bl seems to be ok in both versions(5.0.4
and 5.0.5). Same problem i have with while (list ($key, $value) = each
($this->bl)), in 5.0.4 it works and in 5.0.5 not. Server config is here
wp1011644.wp021.webpack.hosteurope.de/phpinfo.php
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/34752
--
Edit this bug report at http://bugs.php.net/?id=34752&edit=1
Thread (10 messages)