diff options
-rw-r--r-- | Zend/tests/bug79022.phpt | 39 | ||||
-rw-r--r-- | Zend/zend_builtin_functions.c | 6 |
2 files changed, 42 insertions, 3 deletions
diff --git a/Zend/tests/bug79022.phpt b/Zend/tests/bug79022.phpt new file mode 100644 index 0000000000..0657b20355 --- /dev/null +++ b/Zend/tests/bug79022.phpt @@ -0,0 +1,39 @@ +--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 {}"); + } + + if ($class == 'Dummy') { + eval ("class Dummy implements iFoo {}"); + } + + + if (interface_exists('iFoo', 0)) { + new Dummy(); + } + if ($class == 'iFoo') { + eval ("interface iFoo extends iBar {}"); + } + + if ($class == 'iBar') { + eval ("interface iBar {}"); + } +} +spl_autoload_register('my_autoloader'); +new Foo(); +new Dummy(); +echo "okey"; +?> +--EXPECT-- +okey diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 2832fb3e0a..b24d620c71 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1248,7 +1248,7 @@ static inline void class_exists_impl(INTERNAL_FUNCTION_PARAMETERS, int flags, in } if (ce) { - RETURN_BOOL((flags == 0 || (ce->ce_flags & flags)) && !(ce->ce_flags & skip_flags)); + RETURN_BOOL(((ce->ce_flags & flags) == flags) && !(ce->ce_flags & skip_flags)); } else { RETURN_FALSE; } @@ -1259,7 +1259,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); } /* }}} */ @@ -1267,7 +1267,7 @@ ZEND_FUNCTION(class_exists) Checks if the class exists */ ZEND_FUNCTION(interface_exists) { - class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_INTERFACE, 0); + class_exists_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_LINKED|ZEND_ACC_INTERFACE, 0); } /* }}} */ |