ID: 36814 Updated by: [EMAIL PROTECTED] Reported By: raphaelpereira at gmail dot com -Status: Open +Status: Bogus Bug Type: SPL related -Operating System: Ubuntu Hoary +Operating System: * -PHP Version: 5.1.2 +PHP Version: * -Assigned To: +Assigned To: helly New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php There is no need for offsetGet to first call offsetExists from an engine point of view. If there is a need for this it is either a problem in the way you either overload ArrayObject/ArrayIterator or use them. Unless you can provide code that demonstrates an issue in ArrayObject itself i assume there is a problem in usage. Maybe you should note that offsetExists indeed always checks for pure existance rather than working like empty() or isset() do. Even if invoked by them. Previous Comments: ------------------------------------------------------------------------ [2006-03-21 15:50:41] raphaelpereira at gmail dot com Description: ------------ My code is very complex and I could not reproduce the bug in another code, but the issue is that it seems that ArrayObject::offsetGet doesn't check if the key exists to return it and in some very specific case this returns invalid results. The problem is in my query_constraints class. On its constructor I declare: class query_constraints { protected $_dados; public function __construct ($params=null) { $this->_dados = new ArrayObject(); $this->_dados['in'] = new ArrayObject(); $this->_dados['eq'] = new ArrayObject(); ... Later on I have: public function equal($campo, $valor) { if (!$this->_dados['eq'][$campo] && !$this->_dados['in'][$campo]) { ... Both tests returns false on the first call to this method just after object construction. To workaroud the problem I substituted all references to ArrayObject in this class with the following class: class ArrayObject1 extends ArrayObject { public function offsetget($key) { if ($this->offsetexists($key)) return parent::offsetget($key); return null; } } This solved my problem. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36814&edit=1
