Bug #77704 [Opn->Nab]: constant with namespace is not fetchable
Edit report at https://bugs.php.net/bug.php?id=77704&edit=1
ID: 77704
Updated by: cmb@php.net
Reported by: eglic at ziima dot cn
Summary: constant with namespace is not fetchable
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 7.2.15
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> constant name is changed to "foo\\BAR"
Indeed, so you should use:
zval *c = zend_get_constant_str(ZEND_STRL("foo\\BAR"));
Previous Comments:
------------------------------------------------------------------------
[2019-03-06 10:32:49] eglic at ziima dot cn
Description:
------------
in php-7.2.15 source 'Zend/zend_constants.c':
ZEND_API int zend_register_constant(zend_constant *c)
{
...
#479 char *slash = strrchr(ZSTR_VAL(c->name), '\\');
...
#482 zend_str_tolower(ZSTR_VAL(lowercase_name), slash - ZSTR_VAL(c->name));
-----------
constant name is changed to "foo\\BAR"
but in the same file
#243 ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len)
...
#250 zend_str_tolower_copy(lcname, name, name_len);
---------
use "Foo\\BAR" to find first,and try "foo\\bar" again.
both faied.
Test script:
---------------
1. REGISTER_NS_STRING_CONSTANT("Foo", "BAR", "Test", CONST_CS |
CONST_PERSISTENT);
2. zval *c = zend_get_constant_str(ZEND_STRL("Foo\\BAR"));
it returns NULL;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77704&edit=1
Thread (2 messages)