]> granicus.if.org Git - php/commitdiff
Fixed bug #79022 (class_exists returns True for classes that are not ready to be...
authorXinchen Hui <laruence@gmail.com>
Tue, 24 Dec 2019 06:04:19 +0000 (14:04 +0800)
committerXinchen Hui <laruence@gmail.com>
Tue, 24 Dec 2019 06:04:19 +0000 (14:04 +0800)
NEWS
Zend/tests/bug79022.phpt [new file with mode: 0644]
Zend/zend_builtin_functions.c

diff --git a/NEWS b/NEWS
index a3788adaca0c76925e03e50b874e1d0943515c85..881d0c8697bc721f120b39e95fd2203432ad8146 100644 (file)
--- 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 (file)
index 0000000..252effd
--- /dev/null
@@ -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
index d3bf032c1085a2193a6a6e06fdacb64d04e42930..f4733d7b1fe5a574acc7abd047d47bb65065a96e 100644 (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);
 }
 /* }}} */