Skip to content

Instantly share code, notes, and snippets.

@nikic
Created January 15, 2019 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikic/c4c4ac241da02af410ce4f720c31d628 to your computer and use it in GitHub Desktop.
Save nikic/c4c4ac241da02af410ce4f720c31d628 to your computer and use it in GitHub Desktop.
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index e149eeb2ed..e81e501e12 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -1360,9 +1360,8 @@ static fcgi_request *fpm_init_request(int listen_fd) /* {{{ */ {
static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg) /* {{{ */
{
int *mode = (int *)arg;
- char *key;
- char *value = NULL;
- struct key_value_s kv;
+ zend_string *key;
+ zend_string *value = NULL;
if (!mode || !arg1) return;
@@ -1371,27 +1370,20 @@ static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_
return;
}
- key = Z_STRVAL_P(arg1);
-
- if (!key || strlen(key) < 1) {
+ key = Z_STR_P(arg1);
+ if (ZSTR_LEN(key) < 1) {
zlog(ZLOG_ERROR, "Passing INI directive through FastCGI: empty key");
return;
}
- if (arg2) {
- value = Z_STRVAL_P(arg2);
- }
-
- if (!value) {
- zlog(ZLOG_ERROR, "Passing INI directive through FastCGI: empty value for key '%s'", key);
+ if (!arg2) {
+ zlog(ZLOG_ERROR, "Passing INI directive through FastCGI: empty value for key '%s'", ZSTR_VAL(key));
return;
}
- kv.key = key;
- kv.value = value;
- kv.next = NULL;
- if (fpm_php_apply_defines_ex(&kv, *mode) == -1) {
- zlog(ZLOG_ERROR, "Passing INI directive through FastCGI: unable to set '%s'", key);
+ value = Z_STR_P(arg2);
+ if (zend_alter_ini_entry_ex(key, value, *mode, ZEND_INI_STAGE_ACTIVATE, 0) == FAILURE) {
+ zlog(ZLOG_ERROR, "Passing INI directive through FastCGI: unable to set '%s'", ZSTR_VAL(key));
}
}
/* }}} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment