From ce5c38af25c551e99573a7bbd1267a5e5474e1c2 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 3 Oct 2007 10:33:45 +0000 Subject: [PATCH] Fixed bug #42820 (defined() on constant with namespace prefixes tries to load class). --- Zend/tests/bug42820.phpt | 31 +++++++++++++++++++++++++++++++ Zend/zend_builtin_functions.c | 2 +- Zend/zend_compile.h | 3 ++- Zend/zend_constants.c | 8 +++++--- Zend/zend_execute_API.c | 13 ++++++++----- 5 files changed, 47 insertions(+), 10 deletions(-) create mode 100755 Zend/tests/bug42820.phpt diff --git a/Zend/tests/bug42820.phpt b/Zend/tests/bug42820.phpt new file mode 100755 index 0000000000..0a6c7d7876 --- /dev/null +++ b/Zend/tests/bug42820.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #42820 (defined() on constant with namespace prefixes tries to load class) +--FILE-- + name.u && *(colon.u-1) == ':') || @@ -453,7 +453,9 @@ ZEND_API int zend_u_get_constant_ex(zend_uchar type, zstr name, uint name_len, z 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; } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 55a7351ab0..baf0839f3a 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1700,9 +1700,10 @@ ZEND_API zend_class_entry *zend_u_fetch_class(zend_uchar type, zstr class_name, 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 @@ check_fetch_type: } 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) { -- 2.50.1