]> granicus.if.org Git - php/commitdiff
- Fixed bug #51791 (constant() aborts execution when fail to check undefined constant)
authorFelipe Pena <felipe@php.net>
Thu, 13 May 2010 02:13:30 +0000 (02:13 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 13 May 2010 02:13:30 +0000 (02:13 +0000)
Zend/tests/bug51791.phpt [new file with mode: 0644]
ext/standard/basic_functions.c

diff --git a/Zend/tests/bug51791.phpt b/Zend/tests/bug51791.phpt
new file mode 100644 (file)
index 0000000..b6ced4b
--- /dev/null
@@ -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
index 88ea346a7ee63d6224c2dd0be9cbe2c8da212191..fd16d4a1236b9b7c5b077b8636b11b72e04b63a4 100644 (file)
@@ -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();
        }