cvs: ZendEngine2 / zend_builtin_functions.c /tests bug46813.phpt

"Johannes Schl??ter" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsjohannes1228850182@cvsserver>
johannes		Tue Dec  9 19:16:22 2008 UTC

  Added files:                 
    /ZendEngine2/tests	bug46813.phpt 

  Modified files:              
    /ZendEngine2	zend_builtin_functions.c 
  Log:
  Fix #46813 (class_exists doesn`t work with fully qualified namespace)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.389&r2=1.390&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.389 ZendEngine2/zend_builtin_functions.c:1.390
--- ZendEngine2/zend_builtin_functions.c:1.389	Mon Nov 17 22:15:13 2008
+++ ZendEngine2/zend_builtin_functions.c	Tue Dec  9 19:16:22 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.389 2008/11/17 22:15:13 felipe Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.390 2008/12/09 19:16:22 johannes Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -1160,8 +1160,24 @@
 	}
 
 	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));
 	}

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug46813.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug46813.phpt
+++ ZendEngine2/tests/bug46813.phpt
--TEST--
Bug #46813: class_exists doesn`t work with fully qualified namespace
--FILE--
<?php
namespace test;
{
	class inner
	{
		
	}
}

$inner = new \test\inner();

echo "autoload == true:\n";
var_dump(class_exists('\test\inner', true));
var_dump(class_exists(b'\test\inner', true));
echo "autoload == false:\n";
var_dump(class_exists('\test\inner', true));
var_dump(class_exists(b'\test\inner', true));
?>
--EXPECT--
autoload == true:
bool(true)
bool(true)
autoload == false:
bool(true)
bool(true)



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.