]> granicus.if.org Git - php/commitdiff
Fixed bug #42798 (__autoload() not triggered for classes used in method signature).
authorDmitry Stogov <dmitry@php.net>
Mon, 1 Oct 2007 09:33:02 +0000 (09:33 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 1 Oct 2007 09:33:02 +0000 (09:33 +0000)
Zend/tests/bug42798.phpt [new file with mode: 0644]
Zend/zend_constants.c
Zend/zend_execute_API.c

diff --git a/Zend/tests/bug42798.phpt b/Zend/tests/bug42798.phpt
new file mode 100644 (file)
index 0000000..1c45867
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #42798 (_autoload() not triggered for classes used in method signature)
+--FILE--
+<?php
+function __autoload($className) {
+    print "$className\n";
+    exit();
+}
+
+function foo($c = ok::constant) {
+}
+
+foo();
+--EXPECT--
+ok
index 06b25c3a20fd71e8ade8a4b3d9c5bf789262fa95..14bdf6a94a00e0cdb240df55d28d3a52a7dddcdf 100644 (file)
@@ -434,8 +434,10 @@ ZEND_API int zend_u_get_constant_ex(zend_uchar type, zstr name, uint name_len, z
                        }
                        efree(lcname.v);
 
-                       /* Check for class */
-                       ce = zend_u_fetch_class(type, class_name, class_name_len, flags TSRMLS_CC);
+                       if ((flags & IS_CONSTANT_RT_NS_CHECK) == 0) {
+                               /* Check for class */
+                               ce = zend_u_fetch_class(type, class_name, class_name_len, flags TSRMLS_CC);
+                       }
                }
 
                if (retval && ce) {
index 245ed90080c7871e046eeb019472117df8f1b386..3e2ba09ed3835ce9b9fb214d49f19195a69a7b12 100644 (file)
@@ -478,6 +478,7 @@ ZEND_API int zend_is_true(zval *op) /* {{{ */
 
 #define IS_VISITED_CONSTANT       IS_CONSTANT_INDEX
 #define IS_CONSTANT_VISITED(p)    (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
+#define Z_REAL_TYPE_P(p)          (Z_TYPE_P(p) & ~IS_VISITED_CONSTANT)
 #define MARK_CONSTANT_VISITED(p)  Z_TYPE_P(p) |= IS_VISITED_CONSTANT
 
 ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC) /* {{{ */
@@ -501,7 +502,7 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
                refcount = p->refcount;
                is_ref = p->is_ref;
 
-               if (!zend_u_get_constant_ex(ZEND_STR_TYPE, Z_UNIVAL_P(p), Z_UNILEN_P(p), &const_value, scope, Z_TYPE_P(p) TSRMLS_CC)) {
+               if (!zend_u_get_constant_ex(ZEND_STR_TYPE, Z_UNIVAL_P(p), Z_UNILEN_P(p), &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {
                        if ((UG(unicode) && (colon.u = u_memrchr(Z_USTRVAL_P(p), ':', Z_USTRLEN_P(p))) && colon.u > Z_USTRVAL_P(p) && *(colon.u-1) == ':') ||
                            (!UG(unicode) && (colon.s = zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p))) && colon.s > Z_STRVAL_P(p) && *(colon.s-1) == ':')) {
                        if (UG(unicode)) {