Skip to content

Commit 153c9cc

Browse files
committed
Fixed bug #79022 (class_exists returns True for classes that are not ready to be used)
1 parent b829ea5 commit 153c9cc

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PHP NEWS
44
?? ??? ????, PHP 7.4.2
55

66
- Core:
7+
. Fixed bug #79022 (class_exists returns True for classes that are not ready
8+
to be used). (Laruence)
79
. Fixed bug #78929 (plus signs in cookie values are converted to spaces).
810
(Alexey Kachalin)
911
. Fixed bug #78973 (Destructor during CV freeing causes segfault if opline

Zend/tests/bug79022.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #79022 (class_exists returns True for classes that are not ready to be used)
3+
--FILE--
4+
<?php
5+
function my_autoloader($class) {
6+
if (class_exists('Foo', 0)) {
7+
new Foo();
8+
}
9+
if ($class == 'Foo') {
10+
eval("class Foo extends Bar{}");
11+
}
12+
13+
if ($class == 'Bar') {
14+
eval("class Bar {}");
15+
}
16+
}
17+
spl_autoload_register('my_autoloader');
18+
new Foo();
19+
echo "okey";
20+
?>
21+
--EXPECT--
22+
okey

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, int flags, in
14871487
Checks if the class exists */
14881488
ZEND_FUNCTION(class_exists)
14891489
{
1490-
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT);
1490+
class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED, ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT);
14911491
}
14921492
/* }}} */
14931493

0 commit comments

Comments
 (0)