summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-05-13 02:13:30 +0000
committerFelipe Pena <felipe@php.net>2010-05-13 02:13:30 +0000
commitbcd9a87e2ad555eed8b750e6d72adc355e829aaf (patch)
treed04f606a0774d89601c8fb929c856d8f4564608d
parentec93c50c3f1478be5b02ee1d0ae16bde3e3c0e02 (diff)
downloadphp-git-bcd9a87e2ad555eed8b750e6d72adc355e829aaf.tar.gz
- Fixed bug #51791 (constant() aborts execution when fail to check undefined constant)
-rw-r--r--Zend/tests/bug51791.phpt14
-rw-r--r--ext/standard/basic_functions.c2
2 files changed, 15 insertions, 1 deletions
diff --git a/Zend/tests/bug51791.phpt b/Zend/tests/bug51791.phpt
new file mode 100644
index 0000000000..b6ced4bccd
--- /dev/null
+++ b/Zend/tests/bug51791.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #51791 (constant() failed to check undefined constant and php interpreter stoped)
+--FILE--
+<?php
+
+class A {
+ const B = 1;
+}
+var_dump(constant('A::B1'));
+
+?>
+--EXPECTF--
+Warning: constant(): Couldn't find constant A::B1 in %s on line %d
+NULL
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 88ea346a7e..fd16d4a123 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -3771,7 +3771,7 @@ PHP_FUNCTION(constant)
return;
}
- if (!zend_get_constant_ex(const_name, const_name_len, return_value, NULL, 0 TSRMLS_CC)) {
+ if (!zend_get_constant_ex(const_name, const_name_len, return_value, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't find constant %s", const_name);
RETURN_NULL();
}