#31300 [Com]: ArrayAccess and __get crash when using string concat in key

2005-03-04 Thread matt dot bevan at marginsoftware dot com
 ID:   31300
 Comment by:   matt dot bevan at marginsoftware dot com
 Reported By:  gardan at gmx dot com
 Status:   Verified
 Bug Type: Zend Engine 2 problem
 Operating System: *
 PHP Version:  5CVS-2005-01-10
 New Comment:

Consider this bug confirmed using Apache/2.0.52   
(Gentoo/Linux) PHP/5.0.3 but is not re-producible in a 
small amount of code. 
 
In my case, performing strange acts got around the bug 
when using the array access more than once with three 
other variable assignments in-between the first call and 
second: 
 - The first dot-concatenated call worked fine. 
 - The second segfaulted Apache, unless: 
- The first call is commented out, or 
- The second call is placed right below the first, or 
- One line of three lines is commented out. 
- All array accesses are changed to use sprintf 
  not dot concatenation. 
 
It doesn't matter which line of the three simple, static 
variable assignments is commented.

This bug drove me crazy all today.  I'm going to have  
nightmares about this bug.  ;)


Previous Comments:


[2005-01-11 08:24:01] [EMAIL PROTECTED]

ArrayAccess is defined and controlled by the engine not SPL



[2004-12-26 22:40:38] gardan at gmx dot com

Still crashing with cvs snapshot (Windows).



[2004-12-26 12:24:08] [EMAIL PROTECTED]

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



[2004-12-26 07:32:35] Beater at orgalan dot de

I can partially confirm this for 5.0.3 running on Windows XP. The
behaviour is very unpredictable.

Following you'll find some test cases and the behaviour on my system.

class arr implements ArrayAccess {
public $x = array("ab_cd" => "hello");
function offsetExists($offset) { return isset($this->x[$offset]); }
function offsetSet($offset, $value) { $this->x[$offset] = $value; }
function offsetGet($offset) { return $this->x[$offset]; }
function offsetUnset($offset) { unset($this->x[$offset]); }
function __get($offset) { return $this->x[$offset]; }
}
$test = new arr;

case 1:

echo($test["ab"."_cd"]);// crashs

case 2:

echo($test["ab_cd"]);   // works
echo($test["ab"."_cd"]);// works

case 3:
echo($test["ab_cd"]);   // works
echo($test->{"ab_cd"}); // works
echo($test["ab"."_cd"]);// crashs

sounds stupid, but you'll confirm it, i guess



[2004-12-26 07:06:45] gardan at gmx dot com

Description:

When executing the posted code, PHP 5.0.2 and 5.0.3rc-2 crash and kill
apache on the first echo. When uncommenting the first echo, it crashes
on the second one.

Like this

echo($test["ab_cd"]);
echo($test->{"ab_cd"});

it works.

Reproduce code:
---
class arr implements ArrayAccess {
public $x = array("ab_cd" => "hello");
function offsetExists($offset) { return isset($this->x[$offset]); }
function offsetSet($offset, $value) { $this->x[$offset] = $value; }
function offsetGet($offset) { return $this->x[$offset]; }
function offsetUnset($offset) { unset($this->x[$offset]); }
function __get($offset) { return $this->x[$offset]; }
}
$test = new arr;
echo($test["ab_cd"]);   // works
echo($test->{"ab_cd"}); // works
echo($test["ab"."_cd"]);// crash
echo($test->{"ab"."_cd"});  // crash


Expected result:

hellohellohellohello

Actual result:
--
hellohello 
Windows Apache Log:
Parent: child process exited with status 3221225477 -- Restarting





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


#29426 [Com]: Incomplete/inconsistent functionality

2004-10-05 Thread matt dot bevan at marginsoftware dot com
 ID:   29426
 Comment by:   matt dot bevan at marginsoftware dot com
 Reported By:  php at peterrobins dot co dot uk
 Status:   Open
 Bug Type: SimpleXML related
 Operating System: Linux 2.4
 PHP Version:  5.0.0
 New Comment:

I am also in the position where I need to be able to 
create and insert a SimpleXMLElement before or after an 
arbitrary SimpleXMLElement, then remove the previous 
instance.  This is to move XML elements from one location 
in an XML file into another. 
 
I'll likely be switching to/from a DOM object to 
accomplish this, however.


Previous Comments:


[2004-09-19 17:40:18] phpbugs at ilibi dot com

Either the documentation for simplexml should be 
clarified about exactly what can and can not be added/
edited. Or the ability to add nodes should be added to 
simplexml.



[2004-08-08 01:18:36] cyberlot at cyberlot dot net

Confirming this bug exists, Have the same problem, I need to add to a
simplexml object on the fly and can't



[2004-07-28 13:22:59] php at peterrobins dot co dot uk

Description:

According to the manual page, you can add a node with 
SimpleXML, but this does not seem to work, either as  
$xml->movie[0]->characters[0]->character[0]->age = '21'; 
nor as 
$xml->movie[0]->rating[2] = 'not bad'; 
 
Deletion works on attributes 
unset($xml->movie[0]->rating[1]['type']); 
but at node level, deletes all  
unset($xml->movie[0]->rating); 
This is inconsistent with reading where 
$xml->movie[0]->rating 
fetches the first node only. 
unset($xml->movie->rating); 
deletes all ratings for the 1st movie only. 
It does not appear possible to delete just 1 node 
unset($xml->movie[0]->rating[1]); 
 
Because objs are now refs not copies, can do this 
$rat = $xml->movie[0]->rating[0]; 
$rat['name'] = 'judge'; 
but not this 
$rat = 'new content'; 
nor this 
$rat->child[0] = 'new rating'; 
and if I try and do 
$rat->child = 'new rating'; 
I get 'Attempt to assign property of non-object' 
 






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