cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_execute_API.c /tests instanceof.phpt php-src NEWS
| From: | Dmitry Stogov | Date: | Fri, 19 Aug 2005 08:11:17 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_execute_API.c /tests instanceof.phpt php-src NEWS | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4050@lists.php.net to get a copy of this message | ||
dmitry Fri Aug 19 04:11:17 2005 EDT
Added files:
/ZendEngine2/tests instanceof.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_compile.c zend_compile.h zend_execute_API.c
Log:
nstanceof operator shouldn't call __autoload()
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2043&r2=1.2044&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2043 php-src/NEWS:1.2044
--- php-src/NEWS:1.2043 Wed Aug 17 12:57:15 2005
+++ php-src/NEWS Fri Aug 19 04:11:13 2005
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 6.0
- Unicode support. (Andrei, Dmitriy, et al)
+- instanceof operator shouldn't 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.
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.654&r2=1.655&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.654 ZendEngine2/zend_compile.c:1.655
--- ZendEngine2/zend_compile.c:1.654 Tue Aug 16 14:21:04 2005
+++ ZendEngine2/zend_compile.c Fri Aug 19 04:11:15 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.654 2005/08/16 18:21:04 andrei Exp $ */
+/* $Id: zend_compile.c,v 1.655 2005/08/19 08:11:15 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -3592,8 +3592,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.319&r2=1.320&ty=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.319 ZendEngine2/zend_compile.h:1.320
--- ZendEngine2/zend_compile.h:1.319 Fri Aug 12 07:29:26 2005
+++ ZendEngine2/zend_compile.h Fri Aug 19 04:11:16 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.319 2005/08/12 11:29:26 dmitry Exp $ */
+/* $Id: zend_compile.h,v 1.320 2005/08/19 08:11:16 dmitry Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -597,7 +597,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_API.c?r1=1.333&r2=1.334&ty=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.333 ZendEngine2/zend_execute_API.c:1.334
--- ZendEngine2/zend_execute_API.c:1.333 Fri Aug 12 10:58:29 2005
+++ ZendEngine2/zend_execute_API.c Fri Aug 19 04:11:16 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.333 2005/08/12 14:58:29 dmitry Exp $ */
+/* $Id: zend_execute_API.c,v 1.334 2005/08/19 08:11:16 dmitry Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -1421,7 +1421,9 @@
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;
+ fetch_type = fetch_type & ~ZEND_FETCH_CLASS_NO_AUTOLOAD;
check_fetch_type:
switch (fetch_type) {
case ZEND_FETCH_CLASS_SELF:
@@ -1446,14 +1448,27 @@
break;
}
- if (zend_u_lookup_class(type, class_name, class_name_len, &pce TSRMLS_CC)==FAILURE) {
- if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
- zend_error(E_ERROR, "Interface '%R' not found", type, class_name);
+ if (use_autoload) {
+ if (zend_u_lookup_class(type, class_name, class_name_len, &pce TSRMLS_CC)==FAILURE) {
+ 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;
+ } 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 {
- zend_error(E_ERROR, "Class '%R' not found", type, class_name);
+ efree(lc_name);
+ return NULL;
}
}
- return *pce;
}
zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC)
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)