Skip to content

Commit aacba43

Browse files
committed
Fixed #72898 PHP_FCGI_CHILDREN is not included in phpinfo()
1 parent da5e09a commit aacba43

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

sapi/cgi/cgi_main.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,22 @@ consult the installation file that came with this distribution, or visit \n\
20182018
/* This is the number of concurrent requests, equals FCGI_MAX_CONNS */
20192019
fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, children_str, strlen(children_str));
20202020
} else {
2021+
#ifdef PHP_WIN32
2022+
/* If this env var is set, the process was invoked as a child. Let
2023+
it show the original PHP_FCGI_CHILDREN value, while don't care
2024+
otherwise. */
2025+
char * children_str = getenv("PHP_FCGI_CHILDREN_FOR_KID");
2026+
if (children_str) {
2027+
char putenv_buf[sizeof("PHP_FCGI_CHILDREN")+5];
2028+
2029+
snprintf(putenv_buf, sizeof(putenv_buf), "%s=%s", "PHP_FCGI_CHILDREN", children_str);
2030+
putenv(putenv_buf);
2031+
putenv("PHP_FCGI_CHILDREN_FOR_KID=");
2032+
2033+
SetEnvironmentVariable("PHP_FCGI_CHILDREN", children_str);
2034+
SetEnvironmentVariable("PHP_FCGI_CHILDREN_FOR_KID", NULL);
2035+
}
2036+
#endif
20212037
fcgi_set_mgmt_var("FCGI_MAX_CONNS", sizeof("FCGI_MAX_CONNS")-1, "1", sizeof("1")-1);
20222038
fcgi_set_mgmt_var("FCGI_MAX_REQS", sizeof("FCGI_MAX_REQS")-1, "1", sizeof("1")-1);
20232039
}
@@ -2124,6 +2140,10 @@ consult the installation file that came with this distribution, or visit \n\
21242140

21252141
/* kids will inherit the env, don't let them spawn */
21262142
SetEnvironmentVariable("PHP_FCGI_CHILDREN", NULL);
2143+
/* instead, set a temporary env var, so then the child can read and
2144+
show the actual setting correctly. */
2145+
snprintf(kid_buf, 16, "%d", children);
2146+
SetEnvironmentVariable("PHP_FCGI_CHILDREN_FOR_KID", kid_buf);
21272147

21282148
/* The current command line is used as is. This should normally be no issue,
21292149
even if there were some I/O redirection. If some issues turn out, an
@@ -2216,7 +2236,6 @@ consult the installation file that came with this distribution, or visit \n\
22162236
WaitForMultipleObjects(kids, kid_cgi_ps, FALSE, INFINITE);
22172237
}
22182238

2219-
snprintf(kid_buf, 16, "%d", children);
22202239
/* restore my env */
22212240
SetEnvironmentVariable("PHP_FCGI_CHILDREN", kid_buf);
22222241

0 commit comments

Comments
 (0)