logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: ZendEngine2 / zend_builtin_functions.c zend_compile.h zend_constants.c: msg#00024

Subject: cvs: ZendEngine2 / zend_builtin_functions.c zend_compile.h zend_constants.c zend_execute_API.c /tests bug42820.phpt
dmitry          Wed Oct  3 10:33:45 2007 UTC

  Modified files:              
    /ZendEngine2        zend_builtin_functions.c zend_compile.h 
                        zend_constants.c zend_execute_API.c 
    /ZendEngine2/tests  bug42820.phpt 
  Log:
  Fixed bug #42820 (defined() on constant with namespace prefixes tries to load 
class).
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.355&r2=1.356&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.355 
ZendEngine2/zend_builtin_functions.c:1.356
--- ZendEngine2/zend_builtin_functions.c:1.355  Sat Sep 29 02:08:19 2007
+++ ZendEngine2/zend_builtin_functions.c        Wed Oct  3 10:33:45 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.355 2007/09/29 02:08:19 jani Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.356 2007/10/03 10:33:45 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -577,7 +577,7 @@
        }
 
        convert_to_text_ex(var);
-       if (zend_u_get_constant_ex(Z_TYPE_PP(var), Z_UNIVAL_PP(var), 
Z_UNILEN_PP(var), &c, NULL, 0 TSRMLS_CC)) {
+       if (zend_u_get_constant_ex(Z_TYPE_PP(var), Z_UNIVAL_PP(var), 
Z_UNILEN_PP(var), &c, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) {
                zval_dtor(&c);
                RETURN_TRUE;
        } else {
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.365&r2=1.366&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.365 ZendEngine2/zend_compile.h:1.366
--- ZendEngine2/zend_compile.h:1.365    Wed Sep 26 07:16:33 2007
+++ ZendEngine2/zend_compile.h  Wed Oct  3 10:33:45 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.h,v 1.365 2007/09/26 07:16:33 dmitry Exp $ */
+/* $Id: zend_compile.h,v 1.366 2007/10/03 10:33:45 dmitry Exp $ */
 
 #ifndef ZEND_COMPILE_H
 #define ZEND_COMPILE_H
@@ -632,11 +632,12 @@
 #define ZEND_FETCH_CLASS_AUTO          5
 #define ZEND_FETCH_CLASS_INTERFACE     6
 #define ZEND_FETCH_CLASS_STATIC                7
-#define ZEND_FETCH_CLASS_FLAGS        0xF0
+#define ZEND_FETCH_CLASS_MASK         0x0f
 #define ZEND_FETCH_CLASS_NO_NORMALIZE 0x10
 #define ZEND_FETCH_CLASS_RT_NS_CHECK  0x20
 #define ZEND_FETCH_CLASS_RT_NS_NAME   0x40
 #define ZEND_FETCH_CLASS_NO_AUTOLOAD  0x80
+#define ZEND_FETCH_CLASS_SILENT       0x0100
 
 /* variable parsing type (compile-time) */
 #define ZEND_PARSED_MEMBER                             (1<<0)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_constants.c?r1=1.102&r2=1.103&diff_format=u
Index: ZendEngine2/zend_constants.c
diff -u ZendEngine2/zend_constants.c:1.102 ZendEngine2/zend_constants.c:1.103
--- ZendEngine2/zend_constants.c:1.102  Mon Oct  1 09:33:02 2007
+++ ZendEngine2/zend_constants.c        Wed Oct  3 10:33:45 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_constants.c,v 1.102 2007/10/01 09:33:02 dmitry Exp $ */
+/* $Id: zend_constants.c,v 1.103 2007/10/03 10:33:45 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_constants.h"
@@ -321,13 +321,13 @@
            name.u[1] == ':') {
                name.u += 2;
                name_len -= 2;
-               flags = 0;
+               flags &= ZEND_FETCH_CLASS_SILENT;
        } else if (type == IS_STRING &&
                   name.s[0] == ':' &&
                   name.s[1] == ':') {
                name.s += 2;
                name_len -= 2;
-               flags = 0;
+               flags &= ZEND_FETCH_CLASS_SILENT;
        }
 
        if ((UG(unicode) && (colon.u = u_memrchr(name.u, ':', name_len)) && 
colon.u > name.u && *(colon.u-1) == ':') ||
@@ -453,7 +453,9 @@
                                        retval = 1;
                                        return zend_u_get_constant(type, name, 
name_len, result TSRMLS_CC);
                                }
-                               zend_error(E_ERROR, "Class '%R' not found", 
type, class_name);
+                               if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
+                                       zend_error(E_ERROR, "Class '%R' not 
found", type, class_name);
+                               }
                        }
                        retval = 0;
                }
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.419&r2=1.420&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.419 
ZendEngine2/zend_execute_API.c:1.420
--- ZendEngine2/zend_execute_API.c:1.419        Tue Oct  2 08:27:19 2007
+++ ZendEngine2/zend_execute_API.c      Wed Oct  3 10:33:45 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.419 2007/10/02 08:27:19 dmitry Exp $ */
+/* $Id: zend_execute_API.c,v 1.420 2007/10/03 10:33:45 dmitry Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -1700,9 +1700,10 @@
        int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD)  ? 0 : 1;
        int do_normalize = (fetch_type & ZEND_FETCH_CLASS_NO_NORMALIZE) ? 0 : 1;
        int rt_ns_check  = (fetch_type & ZEND_FETCH_CLASS_RT_NS_CHECK)  ? 1 : 0;
+       int silent       = (fetch_type & ZEND_FETCH_CLASS_SILENT) != 0;
        zstr lcname = class_name;
 
-       fetch_type = fetch_type & ~ZEND_FETCH_CLASS_FLAGS;
+       fetch_type &= ZEND_FETCH_CLASS_MASK;
 
 check_fetch_type:
        switch (fetch_type) {
@@ -1780,10 +1781,12 @@
                                }
                                return *pce;
                        }
-                       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);
+                       if (!silent) {
+                               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);
+                               }
                        }
                }
                if (lcname.v != class_name.v) {
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug42820.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug42820.phpt
diff -u /dev/null ZendEngine2/tests/bug42820.phpt:1.2
--- /dev/null   Wed Oct  3 10:33:45 2007
+++ ZendEngine2/tests/bug42820.phpt     Wed Oct  3 10:33:45 2007
@@ -0,0 +1,31 @@
+--TEST--
+Bug #42820 (defined() on constant with namespace prefixes tries to load class)
+--FILE--
+<?php
+namespace ns;
+const ok = 0;
+class foo {
+       const ok = 0;
+}
+var_dump(defined('ns::ok'));
+var_dump(defined('ns::bug'));
+var_dump(defined('::ns::ok'));
+var_dump(defined('::ns::bug'));
+var_dump(defined('ns::foo::ok'));
+var_dump(defined('ns::foo::bug'));
+var_dump(defined('::ns::foo::ok'));
+var_dump(defined('::ns::foo::bug'));
+var_dump(defined('ns::bar::bug'));
+var_dump(defined('::ns::bar::bug'));
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>