mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3'
This commit is contained in:
@@ -213,8 +213,22 @@ static int fpm_conf_expand_pool_name(char **value) {
|
|||||||
static char *fpm_conf_set_boolean(zval *value, void **config, intptr_t offset) /* {{{ */
|
static char *fpm_conf_set_boolean(zval *value, void **config, intptr_t offset) /* {{{ */
|
||||||
{
|
{
|
||||||
zend_string *val = Z_STR_P(value);
|
zend_string *val = Z_STR_P(value);
|
||||||
bool value_y = zend_string_equals_literal(val, "1");
|
/* we need to check all allowed values to correctly set value from the environment variable */
|
||||||
bool value_n = ZSTR_LEN(val) == 0; /* Empty string is the only valid false value */
|
bool value_y = (
|
||||||
|
zend_string_equals_literal(val, "1") ||
|
||||||
|
zend_string_equals_literal(val, "yes") ||
|
||||||
|
zend_string_equals_literal(val, "true") ||
|
||||||
|
zend_string_equals_literal(val, "on")
|
||||||
|
);
|
||||||
|
bool value_n = (
|
||||||
|
value_y || ZSTR_LEN(val) == 0 ||
|
||||||
|
zend_string_equals_literal(val, "0") ||
|
||||||
|
zend_string_equals_literal(val, "no") ||
|
||||||
|
zend_string_equals_literal(val, "none") ||
|
||||||
|
zend_string_equals_literal(val, "false") ||
|
||||||
|
zend_string_equals_literal(val, "off")
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
if (!value_y && !value_n) {
|
if (!value_y && !value_n) {
|
||||||
return "invalid boolean value";
|
return "invalid boolean value";
|
||||||
|
|||||||
75
sapi/fpm/tests/gh13563-conf-bool-env.phpt
Normal file
75
sapi/fpm/tests/gh13563-conf-bool-env.phpt
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
--TEST--
|
||||||
|
FPM: GH-13563 - conf boolean environment variables values
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
include "skipif.inc";
|
||||||
|
FPM\Tester::skipIfRoot();
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "tester.inc";
|
||||||
|
|
||||||
|
$cfg = <<<EOT
|
||||||
|
[global]
|
||||||
|
error_log = {{FILE:LOG}}
|
||||||
|
log_limit = 1024
|
||||||
|
log_buffering = \${FPM_TEST_LOG_BUF}
|
||||||
|
daemonize = \${FPM_TEST_DAEMONIZE}
|
||||||
|
[unconfined]
|
||||||
|
listen = {{ADDR}}
|
||||||
|
process.dumpable = \${FPM_TEST_PROC_DUMP}
|
||||||
|
pm = dynamic
|
||||||
|
pm.max_children = 5
|
||||||
|
pm.start_servers = 1
|
||||||
|
pm.min_spare_servers = 1
|
||||||
|
pm.max_spare_servers = 3
|
||||||
|
request_terminate_timeout_track_finished = \${FPM_TEST_REQ_TERM_TRACK_FIN}
|
||||||
|
catch_workers_output = \${FPM_TEST_CATCH_WRK_OUT}
|
||||||
|
decorate_workers_output = \${FPM_TEST_DECOR_WRK_OUT}
|
||||||
|
clear_env = \${FPM_TEST_CLEAR_ENV}
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$code = <<<EOT
|
||||||
|
<?php
|
||||||
|
foreach (getenv() as \$name => \$val) {
|
||||||
|
if (str_starts_with(\$name, 'FPM_TEST')) {
|
||||||
|
printf("%s: %s\n", \$name, \$val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_put_contents('php://stderr', str_repeat('a', 20) . "\n");
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$tester = new FPM\Tester($cfg, $code);
|
||||||
|
$tester->start(envVars: [
|
||||||
|
'FPM_TEST_LOG_BUF' => 'on',
|
||||||
|
'FPM_TEST_DAEMONIZE' => 'false',
|
||||||
|
'FPM_TEST_PROC_DUMP' => 'no',
|
||||||
|
'FPM_TEST_CATCH_WRK_OUT' => 'yes',
|
||||||
|
'FPM_TEST_DECOR_WRK_OUT' => 'true',
|
||||||
|
'FPM_TEST_CLEAR_ENV' => 'none',
|
||||||
|
'FPM_TEST_REQ_TERM_TRACK_FIN' => '0',
|
||||||
|
]);
|
||||||
|
$tester->expectLogStartNotices();
|
||||||
|
$tester->request()->expectBody([
|
||||||
|
'FPM_TEST_LOG_BUF: on',
|
||||||
|
'FPM_TEST_DAEMONIZE: false',
|
||||||
|
'FPM_TEST_PROC_DUMP: no',
|
||||||
|
'FPM_TEST_CATCH_WRK_OUT: yes',
|
||||||
|
'FPM_TEST_DECOR_WRK_OUT: true',
|
||||||
|
'FPM_TEST_CLEAR_ENV: none',
|
||||||
|
'FPM_TEST_REQ_TERM_TRACK_FIN: 0',
|
||||||
|
]);
|
||||||
|
$tester->terminate();
|
||||||
|
$tester->expectLogMessage('a', 1024, 20, true);
|
||||||
|
$tester->close();
|
||||||
|
|
||||||
|
?>
|
||||||
|
Done
|
||||||
|
--EXPECT--
|
||||||
|
Done
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "tester.inc";
|
||||||
|
FPM\Tester::clean();
|
||||||
|
?>
|
||||||
@@ -514,6 +514,7 @@ class Tester
|
|||||||
bool $daemonize = false,
|
bool $daemonize = false,
|
||||||
array $extensions = [],
|
array $extensions = [],
|
||||||
array $iniEntries = [],
|
array $iniEntries = [],
|
||||||
|
array $envVars = [],
|
||||||
) {
|
) {
|
||||||
$configFile = $this->createConfig();
|
$configFile = $this->createConfig();
|
||||||
$desc = $this->outDesc ? [] : [1 => array('pipe', 'w'), 2 => array('redirect', 1)];
|
$desc = $this->outDesc ? [] : [1 => array('pipe', 'w'), 2 => array('redirect', 1)];
|
||||||
@@ -547,7 +548,7 @@ class Tester
|
|||||||
$cmd = array_merge($cmd, $extraArgs);
|
$cmd = array_merge($cmd, $extraArgs);
|
||||||
$this->trace('Starting FPM using command:', $cmd, true);
|
$this->trace('Starting FPM using command:', $cmd, true);
|
||||||
|
|
||||||
$this->masterProcess = proc_open($cmd, $desc, $pipes);
|
$this->masterProcess = proc_open($cmd, $desc, $pipes, null, $envVars);
|
||||||
register_shutdown_function(
|
register_shutdown_function(
|
||||||
function ($masterProcess) use ($configFile) {
|
function ($masterProcess) use ($configFile) {
|
||||||
@unlink($configFile);
|
@unlink($configFile);
|
||||||
|
|||||||
Reference in New Issue
Block a user