#34259 [NEW]: ArrayAccess interface and Apache crush

From: Date: Thu, 25 Aug 2005 19:46:31 +0000
Subject: #34259 [NEW]: ArrayAccess interface and Apache crush
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-83995@lists.php.net to get a copy of this message
From: gabaden at gmail dot com Operating system: winxp sp2 PHP version: 5.0.4 PHP Bug Type: SPL related Bug description: ArrayAccess interface and Apache crush Description: ------------ ArrayAccess(AA) interface bug. If you try get element of obj, which implements AA interface by index($obj[$index]) and $index — result of any scalar operation($obj[$index+1], it will crush apache server. p.s. sorry for my English. Reproduce code: --------------- [code] class Collection implements ArrayAccess { private $items = null; private $counter = null; function __construct() { $this->items = array(); $this->counter = 0; } function add($obj) { $this->items[$this->counter++] = $obj; } function offsetExists($offset) { if (isset($this->items[$offset])) { return true; } return false; } function offsetGet($offset) { if (isset($this->items[$offset])) { return $this->items[$offset]; } } function offsetSet($offset, $value) { // readonly } function offsetUnset($offset) { // readonly } function count() { return $this->counter; } } $arr = array("key1"=>0, "key2"=>""); $arr["key1"] = 1; $arr["key2"] = "test"; $arr1[] = $arr; $col = new Collection(); $col->add($arr1); $num = $col->count(); if ($num > 0) { for($i=0;$i<$num;$i++) { echo "<pre>"; print_r($col[$i+0]); //crush echo "</pre>"; } } [/code] -- Edit bug report at http://bugs.php.net/?id=34259&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34259&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34259&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34259&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34259&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34259&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34259&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34259&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34259&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34259&r=support Expected behavior: http://bugs.php.net/fix.php?id=34259&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34259&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34259&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34259&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34259&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34259&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34259&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34259&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34259&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34259&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34259&r=mysqlcfg

« previous php.bugs (#83995) next »