|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40442 [PATCH] ArrayObject::offsetExists broke in 5.2.1, works in 5.2.0
Submitted: 2007-02-12 09:10 UTC Modified: 2007-04-06 18:01 UTC
Avg. Score:4.0 ± 1.1
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:1 (20.0%)
From: olivier at elma dot fr Assigned: helly (profile)
Status: Closed Package: SPL related
PHP Version: 5.2.1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: olivier at elma dot fr
New email:
PHP Version: OS:


 [2007-02-12 09:10 UTC] olivier at elma dot fr
With 5.2.0 ArrayObject::offsetExists will return "true" if the offsetExists whether its value is empty or not.
This feature is not working anymore with 5.2.1 as it checks for the emptyness of the value too.

Reproduce code:
$a = new ArrayObject();
$a->offsetSet('property', 0);
if (!$a->offsetExists('property')) {
    echo "does not exist\n";
} else {
    echo "ok\n";

Expected result:

Actual result:
does not exist


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-27 10:10 UTC] olivier at elma dot fr
Just to add the "quick and dirty" patch I use to correct the issue:

--- php-5.2.1/ext/spl/was.spl_array.c   2007-02-09 12:10:18.000000000 +0100
+++ new.php-5.2.1/ext/spl/spl_array.c   2007-02-09 12:06:33.000000000 +0100
@@ -525,7 +525,7 @@
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
-       RETURN_BOOL(spl_array_has_dimension_ex(0, getThis(), index, 1 TSRMLS_CC));
+       RETURN_BOOL(spl_array_has_dimension_ex(0, getThis(), index, 0 TSRMLS_CC));
 } /* }}} */

 /* {{{ proto mixed ArrayObject::offsetGet(mixed $index)
 [2007-03-28 08:48 UTC]
Marcus. any news?
 [2007-03-28 20:16 UTC]
Please try using this CVS snapshot:
For Windows:

 [2007-04-02 12:08 UTC] olivier at elma dot fr
AFAIK it does not change anything...
 [2007-04-06 18:01 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

thanks forthe patch
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 30 20:01:25 2023 UTC