Edit report at https://bugs.php.net/bug.php?id=60067edit=1
ID: 60067
Comment by: bigorangemachine at hotmail dot com
Reported by:bigorangemachine at hotmail dot com
Summary:Strange Recursive/interation
Status: Open
Type: Bug
Package:Variables related
Operating System: Linux CGI/FastCGI
PHP Version:5.3.8
Block user comment: N
Private report: N
New Comment:
FROM (corrected):
if(@in_array($k,$exclude_keys,true)){
if($_type=='object'){
if(!basic_check($omit_str)){unset($obj-{$k});}
else{$obj-{$k}=$omit_str;}
}else if($_type=='array'){
if(!basic_check($omit_str)){unset($obj[$k]);}
else{$obj[$k]=$omit_str;}
}
}else{
if(gettype($v)=='object' ($v instanceof
Traversable)){//
log_clean($obj-{$k},$exclude_keys,$omit_str);}
else if(gettype($v)=='array'){
log_clean($obj[$k],$exclude_keys,$omit_str);}
}
TO (shortened):
if(@in_array($k,$exclude_keys,true)){
if(!basic_check($omit_str)){unset($v);}
else{$v=$omit_str;}
}else{
log_clean($v,$exclude_keys,$omit_str);
}
I changed using $obj[$k] ( and $obj-{$k} [sorry for the syntax error]) to just
using $v in the function log_clean(). This is my first bug report. Sorry if I
don't have the format correct.
Previous Comments:
[2011-10-16 01:15:57] anonymous at anonymous dot anonymous
Needs an SSCCE: http://sscce.org/
[2011-10-15 19:39:27] bigorangemachine at hotmail dot com
Description:
I wrote an OOP PHP class to interact with an Shipping estimate API. I setup a
logging system to help log track any issues during testing.
The goal was to have this logging system remove certain index keys for both
'objects' and 'arrays' in a recursive manor.
I believe that the passed-reference (variable using with an ampersand or what I
call a 'live link') is being 'pushed' up.
When I check the logged xml (in the example) it often read 'omitted'. The
variable was being changed even though the original call to function wasn't
done using a passed-reference.
The function would work correctly with the corrected code or the log_xml calls
completed first. Maybe using $v is what broke the pass reference and it was
just a 'copy' after that.
Test script:
---
Code Sample Here
http://pastebin.com/GcZMkD6B
--
Edit this bug report at https://bugs.php.net/bug.php?id=60067edit=1