Patch is_a_with_warning.txt for Scripting Engine problem Bug #55475
Patch version 2011-09-25 09:32 UTC
Return to Bug #55475 |
Download this patch
Patch Revisions:
Developer: alan_k@php.net
Index: Zend/zend_builtin_functions.c
===================================================================
--- Zend/zend_builtin_functions.c (revision 317267)
+++ Zend/zend_builtin_functions.c (working copy)
@@ -839,13 +839,26 @@
int class_name_len;
zend_class_entry *instance_ce;
zend_class_entry **ce;
+ zend_bool allow_string = only_subclass;
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, &allow_string) == FAILURE) {
return;
}
+ /*
+ is_a() was originaly used as a test for mixed value returns
+ since PHP 5.1 instanceof was fixed to handle this, it is now the recommended way to do this.
+ we can not just break BC straight away, so let's persuade everyone to use instanceof, however they can carry on using
+ is_a() as long as the explicitly give it 3 arguments, otherwise a DEPRCECIATION warning will occur.
+ */
+ if (!only_subclass && ZEND_NUM_ARGS() < 3) {
+ zend_error(E_DEPRECATED,
+ "is_a() testing objects for class names is generally deprecated "
+ " - use instanceof as it now works exactly the same as is_a() does, "
+ " otherwise put false as the 3rd argument to hide this message.");
+ }
- if (Z_TYPE_P(obj) == IS_STRING) {
+ if (allow_string && 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) {
RETURN_FALSE;
|