diff options
author | Xinchen Hui <laruence@gmail.com> | 2016-08-22 23:44:50 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2016-08-22 23:44:50 +0800 |
commit | 6790932eaa8c4dce21080c4094301829fd1f0053 (patch) | |
tree | 46469726a3b014bbd4520f5c80ee83f7b7c00096 | |
parent | d79492c2184a07ecbf48cb0fe7a15769dd7aa2b1 (diff) | |
parent | 434ae90e852ed2b39432baf30d928e26b834c03e (diff) | |
download | php-git-6790932eaa8c4dce21080c4094301829fd1f0053.tar.gz |
Merge branch 'PHP-7.1'
* PHP-7.1:
Fixed bug #72920 (Accessing a private constant using constant() creates an exception AND warning)
-rw-r--r-- | ext/standard/basic_functions.c | 4 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/bug72920.phpt | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 5463665a09..58f9b49151 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3887,7 +3887,9 @@ PHP_FUNCTION(constant) } } } else { - php_error_docref(NULL, E_WARNING, "Couldn't find constant %s", ZSTR_VAL(const_name)); + if (!EG(exception)) { + php_error_docref(NULL, E_WARNING, "Couldn't find constant %s", ZSTR_VAL(const_name)); + } RETURN_NULL(); } } diff --git a/ext/standard/tests/general_functions/bug72920.phpt b/ext/standard/tests/general_functions/bug72920.phpt new file mode 100644 index 0000000000..b5ca4760c3 --- /dev/null +++ b/ext/standard/tests/general_functions/bug72920.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #72920 (Accessing a private constant using constant() creates an exception AND warning) +--FILE-- +<?php +class Foo { + private const C1 = "a"; +} + +try { + var_dump(constant('Foo::C1')); +} catch (Error $e) { + var_dump($e->getMessage()); +} +--EXPECT-- +string(35) "Cannot access private const Foo::C1" |