From: Johannes Schlüter Date: Tue, 9 Dec 2008 19:16:22 +0000 (+0000) Subject: Fix #46813 (class_exists doesn`t work with fully qualified namespace) X-Git-Tag: php-5.4.0alpha1~191^2~4844 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35de188ad3760094f56a83bd5a40d2c2976722c0;p=php Fix #46813 (class_exists doesn`t work with fully qualified namespace) --- diff --git a/Zend/tests/bug46813.phpt b/Zend/tests/bug46813.phpt new file mode 100644 index 0000000000..fb817887ed --- /dev/null +++ b/Zend/tests/bug46813.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #46813: class_exists doesn`t work with fully qualified namespace +--FILE-- + +--EXPECT-- +autoload == true: +bool(true) +bool(true) +autoload == false: +bool(true) +bool(true) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 58bc1292f5..d12bb127c4 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1160,8 +1160,24 @@ ZEND_FUNCTION(class_exists) } if (!autoload) { + zstr name; + int len; + lc_name = zend_u_str_case_fold(type, class_name, class_name_len, 1, &lc_name_len); - found = zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len+1, (void **) &ce); + + /* Ignore leading "\" */ + name = lc_name; + len = class_name_len; + if (lc_name.s[0] == '\\') { + if (type == IS_UNICODE) { + name.u = &lc_name.u[1]; + } else { + name.s = &lc_name.s[1]; + } + len--; + } + + found = zend_u_hash_find(EG(class_table), type, name, len+1, (void **) &ce); efree(lc_name.v); RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & ZEND_ACC_INTERFACE)); }