Fix user ini parsing under RC_DEBUG

Suppress checking during the actual parsing, but make sure to
duplicate strings on activate. The parsing result may be shared
across requests, but activation should work on per-request strings.
This commit is contained in:
Nikita Popov 2021-07-20 16:56:18 +02:00
parent 1da5df8029
commit 21d9931007

View file

@ -782,7 +782,17 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename
/* Reset active ini section */
RESET_ACTIVE_INI_HASH();
#if ZEND_RC_DEBUG
/* User inis are parsed during SAPI activate (part of the request),
* but persistently allocated to allow caching. This is fine as long as
* strings are duplicated in php_ini_activate_config(). */
bool orig_rc_debug = zend_rc_debug;
zend_rc_debug = false;
#endif
ret = zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, target_hash);
#if ZEND_RC_DEBUG
zend_rc_debug = orig_rc_debug;
#endif
if (ret == SUCCESS) {
/* FIXME: Add parsed file to the list of user files read? */
}
@ -803,7 +813,9 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
/* Walk through config hash and alter matching ini entries using the values found in the hash */
ZEND_HASH_FOREACH_STR_KEY_VAL(source_hash, str, data) {
zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0);
zend_string *data_str = zend_string_dup(Z_STR_P(data), 0);
zend_alter_ini_entry_ex(str, data_str, modify_type, stage, 0);
zend_string_release(data_str);
} ZEND_HASH_FOREACH_END();
}
/* }}} */