Skip to content

Commit b839280

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 26f82a7 + d2477b2 commit b839280

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ PHP NEWS
1212
- Mbstring:
1313
. Fixed bug #76958 (Broken UTF7-IMAP conversion). (Nikita)
1414

15+
- Reflection:
16+
. Fixed bug #76936 (Objects cannot access their private attributes while
17+
handling reflection errors). (Nikita)
18+
1519
27 Sep 2018, PHP 7.3.0RC2
1620

1721
- CURL:

Zend/zend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
11851185
zend_stack loop_var_stack;
11861186
zend_stack delayed_oplines_stack;
11871187
zend_array *symbol_table;
1188+
zend_class_entry *orig_fake_scope;
11881189

11891190
/* Report about uncaught exception in case of fatal errors */
11901191
if (EG(exception)) {
@@ -1339,6 +1340,9 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
13391340
CG(in_compilation) = 0;
13401341
}
13411342

1343+
orig_fake_scope = EG(fake_scope);
1344+
EG(fake_scope) = NULL;
1345+
13421346
if (call_user_function(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params) == SUCCESS) {
13431347
if (Z_TYPE(retval) != IS_UNDEF) {
13441348
if (Z_TYPE(retval) == IS_FALSE) {
@@ -1351,6 +1355,8 @@ static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list a
13511355
zend_error_cb(type, error_filename, error_lineno, format, args);
13521356
}
13531357

1358+
EG(fake_scope) = orig_fake_scope;
1359+
13541360
if (in_compilation) {
13551361
CG(active_class_entry) = saved_class_entry;
13561362
RESTORE_STACK(loop_var_stack);

ext/reflection/tests/bug76936.phpt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
Bug #76936: Objects cannot access their private attributes while handling reflection errors
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public $dummy1;
8+
public $dummy2;
9+
}
10+
11+
class ErrorHandler {
12+
private $private = 'THIS IS PRIVATE'."\n";
13+
14+
function __construct() {
15+
set_error_handler(
16+
function ($errno, $errstr, $errfile, $errline) {
17+
$this->handleError($errno, $errstr, $errfile, $errline);
18+
}
19+
);
20+
}
21+
22+
private function handleError($errno, $errstr, $errfile, $errline, $errmodule = null) {
23+
echo __METHOD__. " dealing with error $errstr\n";
24+
25+
// This attribute is no longer accessible in this object. Same for other
26+
// objects and their private attributes once we reach in this state.
27+
echo $this->private;
28+
}
29+
}
30+
31+
$errorHandler = new ErrorHandler();
32+
33+
$f = new Foo;
34+
unset($f->dummy2);
35+
36+
foreach ((new ReflectionObject($f))->getProperties() as $p) {
37+
echo $p->getName() .' = '. $p->getValue($f) ."\n";
38+
}
39+
40+
?>
41+
--EXPECT--
42+
dummy1 =
43+
ErrorHandler::handleError dealing with error Undefined property: Foo::$dummy2
44+
THIS IS PRIVATE
45+
dummy2 =

0 commit comments

Comments
 (0)