cvs: ZendEngine2(PHP_5_3) / zend_builtin_functions.c /tests bug46813.phpt

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

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	bug46813.phpt 

  Modified files:              
    /ZendEngine2	zend_builtin_functions.c 
  Log:
  MFH: Fix #46813 (class_exists doesn`t work with fully qualified namespace)
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.12.2.25.2.36&r2=1.277.2.12.2.25.2.37&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.36 ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.37
--- ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.36	Mon Nov 17 22:21:55 2008
+++ ZendEngine2/zend_builtin_functions.c	Tue Dec  9 19:17:11 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.36 2008/11/17 22:21:55 felipe Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.37 2008/12/09 19:17:11 johannes Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -1157,10 +1157,21 @@
 	}
 
 	if (!autoload) {
+		char *name;
+		int len;
+
 		lc_name = do_alloca(class_name_len + 1, use_heap);
 		zend_str_tolower_copy(lc_name, class_name, class_name_len);
+
+		/* Ignore leading "\" */
+		name = lc_name;
+		len = class_name_len;
+		if (lc_name[0] == '\\') {
+			name = &lc_name[1];
+			len--;
+		}
 	
-		found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
+		found = zend_hash_find(EG(class_table), name, len+1, (void **) &ce);
 		free_alloca(lc_name, use_heap);
 		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.