cvs: ZendEngine2(PHP_5_1) / zend_builtin_functions.c zend_compile.c zend_compile.h zend_execute.h zend_execute_API.c /tests catch.phpt
instanceof.phpt is_a.phpt php-src NEWS

From: Date: Fri, 09 Sep 2005 06:48:50 +0000
Subject: cvs: ZendEngine2(PHP_5_1) / zend_builtin_functions.c zend_compile.c zend_compile.h zend_execute.h zend_execute_API.c /tests catch.phpt
instanceof.phpt is_a.phpt php-src NEWS
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4107@lists.php.net to get a copy of this message
dmitry Fri Sep 9 02:48:50 2005 EDT Added files: (Branch: PHP_5_1) /ZendEngine2/tests catch.phpt instanceof.phpt is_a.phpt Modified files: /php-src NEWS /ZendEngine2 zend_builtin_functions.c zend_compile.c zend_compile.h zend_execute.h zend_execute_API.c Log: Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() functions to not call __autoload().

http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2027.2.54&r2=1.2027.2.55&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.54 php-src/NEWS:1.2027.2.55 --- php-src/NEWS:1.2027.2.54 Thu Sep 8 10:50:23 2005 +++ php-src/NEWS Fri Sep 9 02:48:44 2005 @@ -1,6 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Aug 2005, PHP 5.1 Release Candidate 2 +- Changed "instanceof" and "catch" operators, is_a() and is_subclass_of() + functions to not call __autoload(). (Dmitry) - Added support for class constants and static members for internal classes. (Dmitry, Michael Wallner) - Added "new_link" parameter to mssql_connect(). Bug #34369. (Frank) http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.3&r2=1.277.2.4&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.3 ZendEngine2/zend_builtin_functions.c:1.277.2.4 --- ZendEngine2/zend_builtin_functions.c:1.277.2.3 Thu Sep 1 06:05:31 2005 +++ ZendEngine2/zend_builtin_functions.c Fri Sep 9 02:48:47 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.277.2.3 2005/09/01 10:05:31 dmitry Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.277.2.4 2005/09/09 06:48:47 dmitry Exp $ */ #include "zend.h" #include "zend_API.h" @@ -625,7 +625,7 @@ convert_to_string_ex(class_name); - if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == FAILURE) { + if (zend_lookup_class_ex(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), (instance_ce != NULL), &ce TSRMLS_CC) == FAILURE) { retval = 0; } else { if (only_subclass) { http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.647.2.3&r2=1.647.2.4&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.3 ZendEngine2/zend_compile.c:1.647.2.4 --- ZendEngine2/zend_compile.c:1.647.2.3 Thu Sep 1 06:54:36 2005 +++ ZendEngine2/zend_compile.c Fri Sep 9 02:48:47 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.3 2005/09/01 10:54:36 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.4 2005/09/09 06:48:47 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1712,6 +1712,13 @@ long catch_op_number = get_next_op_number(CG(active_op_array)); zend_op *opline; + if (catch_op_number > 0) { + opline = &CG(active_op_array)->opcodes[catch_op_number-1]; + if (opline->opcode == ZEND_FETCH_CLASS) { + opline->extended_value |= ZEND_FETCH_CLASS_NO_AUTOLOAD; + } + } + opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_CATCH; opline->op1 = *catch_class; @@ -3468,8 +3475,17 @@ void zend_do_instanceof(znode *result, znode *expr, znode *class_znode, int type TSRMLS_DC) { - zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); + int last_op_number = get_next_op_number(CG(active_op_array)); + zend_op *opline; + if (last_op_number > 0) { + opline = &CG(active_op_array)->opcodes[last_op_number-1]; + if (opline->opcode == ZEND_FETCH_CLASS) { + opline->extended_value |= ZEND_FETCH_CLASS_NO_AUTOLOAD; + } + } + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_INSTANCEOF; opline->result.op_type = IS_TMP_VAR; opline->result.u.var = get_temporary_variable(CG(active_op_array)); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.316.2.1&r2=1.316.2.2&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.316.2.1 ZendEngine2/zend_compile.h:1.316.2.2 --- ZendEngine2/zend_compile.h:1.316.2.1 Wed Aug 10 08:02:52 2005 +++ ZendEngine2/zend_compile.h Fri Sep 9 02:48:48 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.316.2.1 2005/08/10 12:02:52 dmitry Exp $ */ +/* $Id: zend_compile.h,v 1.316.2.2 2005/09/09 06:48:48 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -583,7 +583,7 @@ #define ZEND_FETCH_CLASS_GLOBAL 4 #define ZEND_FETCH_CLASS_AUTO 5 #define ZEND_FETCH_CLASS_INTERFACE 6 - +#define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80 /* variable parsing type (compile-time) */ #define ZEND_PARSED_MEMBER (1<<0) http://cvs.php.net/diff.php/ZendEngine2/zend_execute.h?r1=1.84&r2=1.84.2.1&ty=u Index: ZendEngine2/zend_execute.h diff -u ZendEngine2/zend_execute.h:1.84 ZendEngine2/zend_execute.h:1.84.2.1 --- ZendEngine2/zend_execute.h:1.84 Wed Aug 3 09:30:52 2005 +++ ZendEngine2/zend_execute.h Fri Sep 9 02:48:48 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.h,v 1.84 2005/08/03 13:30:52 sniper Exp $ */ +/* $Id: zend_execute.h,v 1.84.2.1 2005/09/09 06:48:48 dmitry Exp $ */ #ifndef ZEND_EXECUTE_H #define ZEND_EXECUTE_H @@ -65,6 +65,7 @@ } } ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); +ZEND_API int zend_lookup_class_ex(char *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); http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.331.2.1&r2=1.331.2.2&ty=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.331.2.1 ZendEngine2/zend_execute_API.c:1.331.2.2 --- ZendEngine2/zend_execute_API.c:1.331.2.1 Fri Sep 2 03:47:27 2005 +++ ZendEngine2/zend_execute_API.c Fri Sep 9 02:48:48 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.331.2.1 2005/09/02 07:47:27 dmitry Exp $ */ +/* $Id: zend_execute_API.c,v 1.331.2.2 2005/09/09 06:48:48 dmitry Exp $ */ #include <stdio.h> #include <signal.h> @@ -908,7 +908,7 @@ } -ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) +ZEND_API int zend_lookup_class_ex(char *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC) { zval **args[1]; zval autoload_function; @@ -936,7 +936,7 @@ /* 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)) { free_alloca(lc_name); return FAILURE; } @@ -1004,6 +1004,11 @@ return retval; } +ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) +{ + return zend_lookup_class_ex(name, name_length, 1, ce TSRMLS_CC); +} + ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) { zval pv; @@ -1329,7 +1334,9 @@ zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC) { zend_class_entry **pce; + int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0; + fetch_type = fetch_type & ~ZEND_FETCH_CLASS_NO_AUTOLOAD; check_fetch_type: switch (fetch_type) { case ZEND_FETCH_CLASS_SELF: @@ -1354,12 +1361,15 @@ break; } - if (zend_lookup_class(class_name, class_name_len, &pce TSRMLS_CC)==FAILURE) { - if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) { - zend_error(E_ERROR, "Interface '%s' not found", class_name); - } else { - zend_error(E_ERROR, "Class '%s' not found", class_name); + if (zend_lookup_class_ex(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 '%s' not found", class_name); + } else { + zend_error(E_ERROR, "Class '%s' not found", class_name); + } } + return NULL; } return *pce; } http://cvs.php.net/co.php/ZendEngine2/tests/catch.phpt?r=1.1&p=1 Index: ZendEngine2/tests/catch.phpt +++ ZendEngine2/tests/catch.phpt --TEST-- catch shouldn't call __autoload --FILE-- <?php function __autoload($name) { echo("AUTOLOAD '$name'\n"); eval("class $name {}"); } try { } catch (A $e) { } try { throw new Exception(); } catch (B $e) { } catch (Exception $e) { echo "ok\n"; } ?> --EXPECT-- ok http://cvs.php.net/co.php/ZendEngine2/tests/instanceof.phpt?r=1.1&p=1 Index: ZendEngine2/tests/instanceof.phpt +++ ZendEngine2/tests/instanceof.phpt --TEST-- instanceof shouldn't call __autoload --FILE-- <?php function __autoload($name) { echo("AUTOLOAD '$name'\n"); eval("class $name {}"); } class A { } $a = new A; var_dump($a instanceof B); var_dump($a instanceof A); ?> --EXPECT-- bool(false) bool(true) http://cvs.php.net/co.php/ZendEngine2/tests/is_a.phpt?r=1.1&p=1 Index: ZendEngine2/tests/is_a.phpt +++ ZendEngine2/tests/is_a.phpt --TEST-- is_a() and is_subclass_of() shouldn't call __autoload --INI-- error_reporting=4095 --FILE-- <?php function __autoload($name) { echo("AUTOLOAD '$name'\n"); eval("class $name {}"); } class BASE { } interface INT { } class A extends BASE implements INT { } $a = new A; var_dump(is_a($a, "B1")); var_dump(is_a($a, "A")); var_dump(is_a($a, "BASE")); var_dump(is_a($a, "INT")); var_dump(is_subclass_of($a, "B2")); var_dump(is_subclass_of($a, "A")); var_dump(is_subclass_of($a, "BASE")); var_dump(is_subclass_of($a, "INT")); ?> --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)
« previous php.zend-engine.cvs (#4107) next »