cvs: ZendEngine2(PHP_5_3) / zend_builtin_functions.c /tests bug47593.phpt php-src NEWS

[email protected] ("Felipe Pena") Sun, 08 Mar 2009 17:28:39 -0000
Newsgroups php.zend-engine.cvs
Message-ID <cvsfelipe1236533319@cvsserver>
felipe		Sun Mar  8 17:28:39 2009 UTC

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

  Modified files:              
    /php-src	NEWS 
    /ZendEngine2	zend_builtin_functions.c 
  Log:
  - MFH: Fixed bug #47593	(interface_exists() returns false when using absolute namespace path)
    patch by Kalle
  - BFN #47572
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.506&r2=1.2027.2.547.2.965.2.507&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.506 php-src/NEWS:1.2027.2.547.2.965.2.507
--- php-src/NEWS:1.2027.2.547.2.965.2.506	Tue Mar  3 23:43:29 2009
+++ php-src/NEWS	Sun Mar  8 17:28:38 2009
@@ -5,6 +5,9 @@
 
 - Re-enabled phar for big-endian systems after fixing problems. (Greg)
 
+- Fixed bug #47593 (interface_exists() returns false when using absolute 
+  namespace path). (Kalle, Felipe)
+- Fixed bug #47572 (Undefined constant causes segmentation fault). (Felipe)
 - Fixed bug #47549 (get_defined_constants() return array with broken
   array categories). (Ilia)
 - Fixed Bug #47443 (metaphone('scratch') returns wrong result). (Felipe)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.12.2.25.2.45&r2=1.277.2.12.2.25.2.46&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.45 ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.46
--- ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.45	Tue Mar  3 23:42:51 2009
+++ ZendEngine2/zend_builtin_functions.c	Sun Mar  8 17:28:38 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.45 2009/03/03 23:42:51 iliaa Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.46 2009/03/08 17:28:38 felipe Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -1228,10 +1228,21 @@
 	}
 
 	if (!autoload) {
+		char *name;
+		int len;
+		
 		lc_name = do_alloca(iface_name_len + 1, use_heap);
 		zend_str_tolower_copy(lc_name, iface_name, iface_name_len);
 	
-		found = zend_hash_find(EG(class_table), lc_name, iface_name_len+1, (void **) &ce);
+		/* Ignore leading "\" */
+		name = lc_name;
+		len = iface_name_len;
+		if (lc_name[0] == '\\') {
+			name = &lc_name[1];
+			len--;
+		}
+
+		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);
 	}
@@ -1260,8 +1271,15 @@
 	}
 
 	lcname = zend_str_tolower_dup(name, name_len);
+	
+	/* Ignore leading "\" */
+	name = lcname;
+	if (lcname[0] == '\\') {
+		name = &lcname[1];
+		name_len--;
+	}
 
-	retval = (zend_hash_find(EG(function_table), lcname, name_len+1, (void **)&func) == SUCCESS);
+	retval = (zend_hash_find(EG(function_table), name, name_len+1, (void **)&func) == SUCCESS);
 	
 	efree(lcname);
 

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug47593.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug47593.phpt
+++ ZendEngine2/tests/bug47593.phpt
--TEST--
Bug #47593 (interface_exists() returns false when using absolute namespace path)
--FILE--
<?php

namespace test;
const TEST = 11;

class foo {
	public function xyz() {
	}
}

interface baz {
}	

function bar() {
}


var_dump(interface_exists('\test\baz'));
var_dump(function_exists('\test\bar'));
var_dump(constant('\test\TEST'));
var_dump(defined('\test\TEST'));
var_dump(defined('TEST'));


?>
--EXPECT--
bool(true)
bool(true)
int(11)
bool(true)
bool(false)