php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55475
Patch final_patch_for_5_4_and_HEAD_v2 revision 2011-11-08 09:24 UTC by alan_k@php.net
Patch is_a_5.4_alternative revision 2011-10-17 13:15 UTC by jbondc at openmv dot com
Patch final_patch_for_5_4_and_HEAD revision 2011-10-13 07:36 UTC by alan_k@php.net
Patch is_a_with_warning.txt revision 2011-09-25 09:32 UTC by alan_k@php.net
Patch Is_a_with_allow_string_argument_v3 revision 2011-09-22 23:31 UTC by alan_k@php.net
Patch Is_a_with_allow_string_argument_v2 revision 2011-09-22 23:26 UTC by alan_k@php.net
Patch Is_a_with_allow_string_argument revision 2011-09-22 23:24 UTC by alan_k@php.net
Patch is_class_of.diff revision 2011-09-20 21:32 UTC by alan_k@php.net
Patch is_class_of.txt revision 2011-09-20 21:25 UTC by alan_k@php.net
Patch revert.is_a.behaviour.to.ignoring.strings.diff revision 2011-08-25 02:37 UTC by alan at akbkhome dot com
Patch bug55475 revision 2011-08-22 10:30 UTC by kalle@php.net

Patch is_a_5.4_alternative for Scripting Engine problem Bug #55475

Patch version 2011-10-17 13:15 UTC

Return to Bug #55475 | Download this patch
Patch Revisions:

Developer: jbondc@openmv.com

Index: Zend/zend_builtin_functions.c
===================================================================
--- Zend/zend_builtin_functions.c	(revision 318163)
+++ Zend/zend_builtin_functions.c	(working copy)
@@ -839,15 +839,16 @@
 	int class_name_len;
 	zend_class_entry *instance_ce;
 	zend_class_entry **ce;
+	zend_bool autoload = 0;
 	zend_bool retval;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &obj, &class_name, &class_name_len) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|b", &obj, &class_name, &class_name_len, &autoload) == FAILURE) {
 		return;
 	}
-	
+
 	if (Z_TYPE_P(obj) == IS_STRING) {
 		zend_class_entry **the_ce;
-		if (zend_lookup_class(Z_STRVAL_P(obj), Z_STRLEN_P(obj), &the_ce TSRMLS_CC) == FAILURE) {
+		if (zend_lookup_class_ex(Z_STRVAL_P(obj), Z_STRLEN_P(obj), NULL, autoload, &the_ce TSRMLS_CC) == FAILURE) {
 			RETURN_FALSE;
 		}
 		instance_ce = *the_ce;
@@ -857,12 +858,12 @@
 		RETURN_FALSE;
 	}
 
-	if (zend_lookup_class_ex(class_name, class_name_len, NULL, 0, &ce TSRMLS_CC) == FAILURE) {
+	if (zend_lookup_class_ex(class_name, class_name_len, NULL, autoload, &ce TSRMLS_CC) == FAILURE) {
 		retval = 0;
 	} else {
 		if (only_subclass && instance_ce == *ce) {
 			retval = 0;
- 		} else {
+		} else {
 			retval = instanceof_function(instance_ce, *ce TSRMLS_CC);
 		}
 	}
Index: Zend/tests/is_a.phpt
===================================================================
--- Zend/tests/is_a.phpt	(revision 318163)
+++ Zend/tests/is_a.phpt	(working copy)
@@ -1,11 +1,17 @@
 --TEST--
-is_a() and is_subclass_of() shouldn't call __autoload
+is_a() and is_subclass_of() __autoload tests.
 --INI--
 error_reporting=14335
 --FILE--
 <?php
 function __autoload($name) {
 	echo("AUTOLOAD '$name'\n");
+
+	if( strstr($name, '_') ) {
+		$t = explode('_', $name, 2);
+		$name = $name .' extends '. $t[1];
+	}
+
 	eval("class $name {}");
 }
 
@@ -27,8 +33,15 @@
 var_dump(is_subclass_of($a, "A"));
 var_dump(is_subclass_of($a, "BASE"));
 var_dump(is_subclass_of($a, "INT"));
-
-var_dump(is_subclass_of("X1", "X2"));
+var_dump(is_subclass_of("s1", "s2"));
+var_dump(is_subclass_of("s1", "s2", true));
+var_dump(is_subclass_of("s4_s3", "s3", true));
+var_dump(is_a("c1", "c2"));
+var_dump(is_a("c4_c3", "c3"));
+var_dump(is_a("c4_c3", "c3", true));
+var_dump(is_a("c5_c4_c3", "c4_c3", true));
+var_dump(is_a("c5_c4_c3", "c3"));
+var_dump(is_subclass_of("c5_c4_c3", "c3"));
 ?>
 --EXPECT--
 bool(false)
@@ -39,5 +52,19 @@
 bool(false)
 bool(true)
 bool(true)
-AUTOLOAD 'X1'
 bool(false)
+AUTOLOAD 's1'
+AUTOLOAD 's2'
+bool(false)
+AUTOLOAD 's4_s3'
+AUTOLOAD 's3'
+bool(true)
+bool(false)
+bool(false)
+AUTOLOAD 'c4_c3'
+AUTOLOAD 'c3'
+bool(true)
+AUTOLOAD 'c5_c4_c3'
+bool(true)
+bool(true)
+bool(true)
\ No newline at end of file
Index: main/php_version.h
===================================================================
--- main/php_version.h	(revision 318163)
+++ main/php_version.h	(working copy)
@@ -3,6 +3,6 @@
 #define PHP_MAJOR_VERSION 5
 #define PHP_MINOR_VERSION 4
 #define PHP_RELEASE_VERSION 0
-#define PHP_EXTRA_VERSION "beta2-dev"
-#define PHP_VERSION "5.4.0beta2-dev"
+#define PHP_EXTRA_VERSION "alpha2-dev"
+#define PHP_VERSION "5.4.0alpha2-dev"
 #define PHP_VERSION_ID 50400
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC