Req #79911 [NEW]: isset - error when using array acess on stdClass
| From: | gregorio at bonfante dot dev | Date: | Tue, 28 Jul 2020 23:14:39 +0000 |
| Subject: | Req #79911 [NEW]: isset - error when using array acess on stdClass | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228259@lists.php.net to get a copy of this message | ||
From: gregorio at bonfante dot dev
Operating system:
PHP version: Irrelevant
Package: Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:isset - error when using array acess on stdClass
Description:
------------
Similar to https://bugs.php.net/bug.php?id=55223
Not a bug, but still not what I expected.
Using array access results in an error if the subject is an object
without ArrayAccess.
Not sure about the solution as I don't have familiarity with the PHP
internals.
I was able to adjust this behavior adding
"""
else if(!check_empty) {
return 0;
}
"""
to 'zend_std_has_dimension' on Zend/zend_object_handlers.c
before the "else { zend_bad_array_access(ce); return 0; }"
Test script:
---------------
<?php
$a = [];
$o = new stdClass();
var_dump(isset($a->prop));
var_dump(isset($o[0]));
Expected result:
----------------
bool(false)
bool(false)
Actual result:
--------------
bool(false)
Fatal error: Uncaught Error: Cannot use object of type stdClass as array
in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
--
Edit bug report at https://bugs.php.net/bug.php?id=79911&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79911&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79911&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79911&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79911&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79911&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79911&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79911&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79911&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79911&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79911&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79911&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79911&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79911&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79911&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79911&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79911&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79911&r=mysqlcfg