Bug #76936 [NEW]: Objects cannot access their private attributes while handling reflection errors
| From: | juanleon dot lahoz at gmail dot com | Date: | Wed, 26 Sep 2018 10:47:02 +0000 |
| Subject: | Bug #76936 [NEW]: Objects cannot access their private attributes while handling reflection errors | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217248@lists.php.net to get a copy of this message | ||
From: juanleon dot lahoz at gmail dot com
Operating system: Linux (Ubuntu 18.04)
PHP version: 7.2.10
Package: Reflection related
Bug Type: Bug
Bug description:Objects cannot access their private attributes while handling reflection errors
Description:
------------
In PHP 7.2, if a error is triggered while using reflection to inspect an
object,
and a error_handler is set as a method of a class, the error handler
object
cannot access its own private attributes.
Short (about 60 lines) and example of the code with comments is here
https://gist.github.com/juan-leon/0c33d86b1bda88b6281fdcf451dc1192
Example code is working for PHP 7.0, and its output is in the expected
results section.
Example code is failing for PHP 7.2, and its output is in the expected
results section (notice the Fatal Error description)
Test script:
---------------
https://gist.github.com/juan-leon/0c33d86b1bda88b6281fdcf451dc1192
Expected result:
----------------
property dummy1 value is 1
Dealing with error Undefined property: Foo::$dummy2,
/home/bb1/www/weird_error5.php, 57
Never executed in PHP7.2; there is a fatal error in the line above
property dummy2 value is
This line is not reached in PHP7.2; but it is reached in PHP 7.0
Actual result:
--------------
property dummy1 value is 1
Dealing with error Undefined property: Foo::$dummy2,
/home/bb1/www/weird_error5.php, 57
Fatal error: Uncaught Error: Cannot access private property
ErrorHandler::$private in /home/bb1/www/weird_error5.php:38
Stack trace:
#0 /home/bb1/www/weird_error5.php(28): ErrorHandler->handleError(8,
'Undefined prope...', '/home/bb1/www/w...', 57)
#1 [internal function]: ErrorHandler->{closure}(8, 'Undefined prope...',
'/home/bb1/www/w...', 57, Array)
#2 /home/bb1/www/weird_error5.php(57):
ReflectionProperty->getValue(Object(Foo))
#3 /home/bb1/www/weird_error5.php(66): reproduceBug(Object(Foo))
#4 {main}
thrown in /home/bb1/www/weird_error5.php on line 38
--
Edit bug report at https://bugs.php.net/bug.php?id=76936&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76936&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76936&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76936&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76936&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76936&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76936&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76936&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76936&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76936&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76936&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76936&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76936&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76936&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76936&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76936&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76936&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76936&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76936&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76936&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76936&r=mysqlcfg