Fixed bug #79022 (class_exists returns True for classes that are not ready to be used)

This commit is contained in:
Xinchen Hui 2019-12-24 14:04:19 +08:00
parent b829ea5f74
commit 153c9cc346
3 changed files with 25 additions and 1 deletions

2
NEWS
View File

@ -4,6 +4,8 @@ PHP NEWS
?? ??? ????, PHP 7.4.2
- Core:
. Fixed bug #79022 (class_exists returns True for classes that are not ready
to be used). (Laruence)
. Fixed bug #78929 (plus signs in cookie values are converted to spaces).
(Alexey Kachalin)
. Fixed bug #78973 (Destructor during CV freeing causes segfault if opline

22
Zend/tests/bug79022.phpt Normal file
View File

@ -0,0 +1,22 @@
--TEST--
Bug #79022 (class_exists returns True for classes that are not ready to be used)
--FILE--
<?php
function my_autoloader($class) {
if (class_exists('Foo', 0)) {
new Foo();
}
if ($class == 'Foo') {
eval("class Foo extends Bar{}");
}
if ($class == 'Bar') {
eval("class Bar {}");
}
}
spl_autoload_register('my_autoloader');
new Foo();
echo "okey";
?>
--EXPECT--
okey

View File

@ -1487,7 +1487,7 @@ static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, int flags, in
Checks if the class exists */
ZEND_FUNCTION(class_exists)
{
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT);
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED, ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT);
}
/* }}} */