php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61347 inconsistent isset behavior of Arrayobject
Submitted: 2012-03-11 05:17 UTC Modified: 2012-03-11 08:34 UTC
From: laruence@php.net Assigned: laruence (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2012-03-11 05:17 UTC] laruence@php.net
Description:
------------
isset(arrayobject['index']) act inconsistently with isset(array['index'])

Test script:
---------------
<?php
$a = array('b' => NULL);
var_dump(isset($a['b']));

$b = new ArrayObject($a);
var_dump(isset($b['b']));

Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
bool(false)
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-11 05:38 UTC] laruence@php.net
these codes are weired(spl_array.c:603):
    switch(Z_TYPE_P(offset)) {
    case IS_STRING:
        if (check_empty) {
            if (zend_symtable_find(spl_array_get_hash_table(intern, 0 
TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != 
FAILURE) {
                switch (check_empty) {
                    case 0:
                        return Z_TYPE_PP(tmp) != IS_NULL;
                    case 2:
                        return 1;
                    default:
                        return zend_is_true(*tmp);
                }
            }
            return 0;
        } else {
            return zend_symtable_exists(spl_array_get_hash_table(intern, 0 
TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
        }


note the switch statement, there is no chance check_empty will be 0, since there 
is a if(check_empty) before.

and, I don't see any chance that the check_empty could be 2. 

any idea? thanks
 [2012-03-11 08:05 UTC] laruence@php.net
one more :

$a = array('b' => "test");
$b = new ArrayObject($a);
var_dump(isset($b->b));

outputed : bool(false)

should this be true?
 [2012-03-11 08:27 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=324093
Log: Fixed bug #61347 (inconsist isset behavior of Arrayobject)
 [2012-03-11 08:31 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2012-03-11 08:31 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-03-11 08:34 UTC] laruence@php.net
-Summary: inconsist isset behavior of Arrayobject +Summary: inconsistent isset behavior of Arrayobject
 [2012-04-18 09:45 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e6ec1fb166bfb22969ed28746b8f952dce05673e
Log: Fixed bug #61347 (inconsist isset behavior of Arrayobject)
 [2012-07-24 23:36 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e6ec1fb166bfb22969ed28746b8f952dce05673e
Log: Fixed bug #61347 (inconsist isset behavior of Arrayobject)
 [2013-11-17 09:33 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e6ec1fb166bfb22969ed28746b8f952dce05673e
Log: Fixed bug #61347 (inconsist isset behavior of Arrayobject)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC