From: Nikita Popov Date: Fri, 15 Feb 2019 12:03:46 +0000 (+0100) Subject: Suppress zend_throw_error during preload constant resolution X-Git-Tag: php-7.4.0alpha1~1036 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ade9d5e95b879def3ce5b2b0c117ce1258c211ee;p=php Suppress zend_throw_error during preload constant resolution Related to bug #77615. --- diff --git a/Zend/zend.c b/Zend/zend.c index 6dc1c9c4cc..f3d501f7e1 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1503,6 +1503,11 @@ ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const c exception_ce = zend_ce_error; } + /* Marker used to disable exception generation during preloading. */ + if (EG(exception) == (void*)(uintptr_t)-1) { + return; + } + va_start(va, format); zend_vspprintf(&message, 0, format, va); diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 303034a4ba..985c66c32e 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3453,11 +3453,11 @@ static void preload_link(void) break; } if (!(ce->ce_flags & ZEND_ACC_LINKED)) { - zend_error(E_WARNING, "Can't preload unlinked class %s at %s:%d\n", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); + zend_error(E_WARNING, "Can't preload unlinked class %s at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); } else if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { - zend_error(E_WARNING, "Can't preload class %s with unresolved constants at %s:%d\n", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); + zend_error(E_WARNING, "Can't preload class %s with unresolved constants at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); } else if (!(ce->ce_flags & ZEND_ACC_PROPERTY_TYPES_RESOLVED)) { - zend_error(E_WARNING, "Can't preload class %s with unresolved property types at %s:%d\n", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); + zend_error(E_WARNING, "Can't preload class %s with unresolved property types at %s:%d", ZSTR_VAL(ce->name), ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start); } else { continue; } diff --git a/ext/opcache/tests/preload_004.phpt b/ext/opcache/tests/preload_004.phpt new file mode 100644 index 0000000000..eed73785f8 --- /dev/null +++ b/ext/opcache/tests/preload_004.phpt @@ -0,0 +1,16 @@ +--TEST-- +Preloading class with undefined class constant access +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload_undef_const.inc +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: Can't preload class Foo with unresolved constants at %s:%d in Unknown on line 0 +bool(false) diff --git a/ext/opcache/tests/preload_undef_const.inc b/ext/opcache/tests/preload_undef_const.inc new file mode 100644 index 0000000000..8d199e0e83 --- /dev/null +++ b/ext/opcache/tests/preload_undef_const.inc @@ -0,0 +1,4 @@ +