summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2019-12-24 14:04:19 +0800
committerXinchen Hui <laruence@gmail.com>2019-12-24 14:04:19 +0800
commit153c9cc346bae927394d3ce1378f77fb7c1e1be3 (patch)
tree70538248e4ff3fe3e769483a7a190bae98161368
parentb829ea5f7410ae570cc8b06c11a466344dd7fd45 (diff)
downloadphp-git-153c9cc346bae927394d3ce1378f77fb7c1e1be3.tar.gz
Fixed bug #79022 (class_exists returns True for classes that are not ready to be used)
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug79022.phpt22
-rw-r--r--Zend/zend_builtin_functions.c2
3 files changed, 25 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index a3788adaca..881d0c8697 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/Zend/tests/bug79022.phpt b/Zend/tests/bug79022.phpt
new file mode 100644
index 0000000000..252effdb31
--- /dev/null
+++ b/Zend/tests/bug79022.phpt
@@ -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
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index d3bf032c10..f4733d7b1f 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -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);
}
/* }}} */