]> granicus.if.org Git - php/commitdiff
catch operator shouldn't call __autoload () too
authorDmitry Stogov <dmitry@php.net>
Thu, 8 Sep 2005 10:32:28 +0000 (10:32 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 8 Sep 2005 10:32:28 +0000 (10:32 +0000)
NEWS
Zend/tests/catch.phpt [new file with mode: 0755]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index 418dade928802e051e73e4509b50c8a620771ad4..b2beb682ab0eb03221f83ed5772ea0f8f9aaf46f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,8 +2,8 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 6.0
 - Unicode support. (Andrei, Dmitriy, et al)
-- Changed "instanceof" operator, is_a() and is_subclass_of() functions to not
-  call __autoload(). (Dmitry)
+- Changed "instanceof" and "catch" operators, is_a() and is_subclass_of()
+  functions to not call __autoload(). (Dmitry)
 - Added optional parameter to http_build_query() to allow specification of 
   string separator.
 - cURL improvements: (Ilia)
diff --git a/Zend/tests/catch.phpt b/Zend/tests/catch.phpt
new file mode 100755 (executable)
index 0000000..0ec5cf7
--- /dev/null
@@ -0,0 +1,23 @@
+--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
index 606e4a9090dcacba456f2a5b700efc01def7390f..fa25254a98f05a8fdadd4234181bbfe8903e2d8e 100644 (file)
@@ -1791,6 +1791,13 @@ void zend_do_begin_catch(znode *try_token, znode *catch_class, znode *catch_var,
        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;