From: Dmitry Stogov Date: Tue, 23 Aug 2005 07:23:30 +0000 (+0000) Subject: Changed is_a() and is_subcalls_of() functions to not call __autoload() (in the same... X-Git-Tag: PRE_NEW_OCI8_EXTENSION~119 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24743055a3b744272457465646dbdee174ae5f81;p=php Changed is_a() and is_subcalls_of() functions to not call __autoload() (in the same way as "instanceof" operator). --- diff --git a/NEWS b/NEWS index 4fd3e8301e..239f0e9ab1 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 6.0 - Unicode support. (Andrei, Dmitriy, et al) -- Changed "instanceof" operator to not call __autoload(). (Dmitry) +- Changed "instanceof" operator, is_a() and is_subcalls_of() functions to not + call __autoload(). (Dmitry) - cURL improvements: (Ilia) . Added curl_setopt_array() which allows setting of multiple cURL options. . Added CURLINFO_HEADER_OUT to facilitate request retrieval. diff --git a/Zend/tests/is_a.phpt b/Zend/tests/is_a.phpt new file mode 100755 index 0000000000..20daf5a5ef --- /dev/null +++ b/Zend/tests/is_a.phpt @@ -0,0 +1,46 @@ +--TEST-- +is_a() and is_subclass_of() shouldn't call __autoload +--INI-- +error_reporting=4095 +--FILE-- + +--EXPECTF-- +Strict Standards: is_a(): Deprecated. Please use the instanceof operator in %sis_a.php on line 17 +bool(false) + +Strict Standards: is_a(): Deprecated. Please use the instanceof operator in %sis_a.php on line 18 +bool(true) + +Strict Standards: is_a(): Deprecated. Please use the instanceof operator in %sis_a.php on line 19 +bool(true) + +Strict Standards: is_a(): Deprecated. Please use the instanceof operator in %sis_a.php on line 20 +bool(true) +bool(false) +bool(false) +bool(true) +bool(false) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index a54da0ee4f..41dbada57a 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -674,7 +674,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) convert_to_text_ex(class_name); - if (zend_u_lookup_class(Z_TYPE_PP(class_name), Z_UNIVAL_PP(class_name), Z_UNILEN_PP(class_name), &ce TSRMLS_CC) == FAILURE) { + if (zend_u_lookup_class_ex(Z_TYPE_PP(class_name), Z_UNIVAL_PP(class_name), Z_UNILEN_PP(class_name), 0, &ce TSRMLS_CC) == FAILURE) { retval = 0; } else { if (only_subclass) { diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index ad05ea7719..40e09203ae 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -66,6 +66,7 @@ static inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LI } ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, zend_class_entry ***ce TSRMLS_DC); +ZEND_API int zend_u_lookup_class_ex(zend_uchar type, void *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC); ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC); ZEND_API int zend_u_eval_string(zend_uchar type, void *str, zval *retval_ptr, char *string_name TSRMLS_DC); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 0c70d9ee16..233dbfe3c0 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -973,7 +973,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS } -ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, zend_class_entry ***ce TSRMLS_DC) +ZEND_API int zend_u_lookup_class_ex(zend_uchar type, void *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC) { zval **args[1]; zval autoload_function; @@ -1001,7 +1001,7 @@ ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, z /* The compiler is not-reentrant. Make sure we __autoload() only during run-time * (doesn't impact fuctionality of __autoload() */ - if (zend_is_compiling(TSRMLS_C)) { + if (!use_autoload || zend_is_compiling(TSRMLS_C)) { efree(lc_name); return FAILURE; } @@ -1073,6 +1073,11 @@ ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, z return retval; } +ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, zend_class_entry ***ce TSRMLS_DC) +{ + return zend_u_lookup_class_ex(type, name, name_length, 1, ce TSRMLS_CC); +} + ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) { return zend_u_lookup_class(IS_STRING, name, name_length, ce TSRMLS_CC); @@ -1429,7 +1434,7 @@ void zend_unset_timeout(TSRMLS_D) ZEND_API zend_class_entry *zend_u_fetch_class(zend_uchar type, void *class_name, uint class_name_len, int fetch_type TSRMLS_DC) { zend_class_entry **pce; - zend_bool use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0; + int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0; fetch_type = fetch_type & ~ZEND_FETCH_CLASS_NO_AUTOLOAD; check_fetch_type: @@ -1456,26 +1461,17 @@ check_fetch_type: break; } - if (use_autoload) { - if (zend_u_lookup_class(type, class_name, class_name_len, &pce TSRMLS_CC)==FAILURE) { + if (zend_u_lookup_class_ex(type, class_name, class_name_len, use_autoload, &pce TSRMLS_CC)==FAILURE) { + if (use_autoload) { if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) { zend_error(E_ERROR, "Interface '%R' not found", type, class_name); } else { zend_error(E_ERROR, "Class '%R' not found", type, class_name); } } - return *pce; + return NULL; } else { - unsigned int lc_name_len; - void *lc_name = zend_u_str_case_fold(type, class_name, class_name_len, 1, &lc_name_len); - - if (zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len+1, (void **) &pce) == SUCCESS) { - efree(lc_name); - return *pce; - } else { - efree(lc_name); - return NULL; - } + return *pce; } }