1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/sapi/fpm/tests/bug75712-getenv-server-vars_001.phpt
Tim Düsterhus 37bf0ec961 main: Deprecate deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string (#19606)
* main: Ignore `register_argc_argv` when `SG(request_info).argc` is available

* sapi: Remove hardcoded `register_argc_argv` for CLI SAPIs

This INI is ignored since the previous commit, which makes the hardcoded
setting obsolete.

* main: Deprecate deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive

* main: Adjust deprecation message for `register_argc_argv`

* NEWS/UPGRADING
2025-09-09 10:34:35 +02:00

69 lines
1.2 KiB
PHP

--TEST--
FPM: bug75712 - getenv should not read from $_ENV and $_SERVER
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
require_once "tester.inc";
$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
[unconfined]
listen = {{ADDR}}
pm = static
pm.max_children = 1
env[TEST] = test
php_value[register_argc_argv] = on
php_value[html_errors] = off
EOT;
$code = <<<EOT
<?php
var_dump(isset(getenv()['argv']));
var_dump(isset(getenv()['SERVER_NAME']));
var_dump(getenv()['TEST']);
var_dump(isset(getenv()['DTEST']));
var_dump(getenv('DTEST'));
putenv('DTEST=dt');
var_dump(getenv()['DTEST']);
var_dump(getenv('DTEST'));
function notcalled()
{
\$_SERVER['argv'];
}
EOT;
$tester = new FPM\Tester($cfg, $code);
$tester->start();
$tester->expectLogStartNotices();
$response = $tester->request();
echo "=====", PHP_EOL;
$response->printBody();
echo "=====", PHP_EOL;
$tester->terminate();
$tester->close();
?>
Done
--EXPECTF--
=====
Deprecated: Deriving $_SERVER['argv'] from the query string is deprecated. Configure register_argc_argv=0 to turn this message off in %s on line %d
bool(false)
bool(true)
string(4) "test"
bool(false)
bool(false)
string(2) "dt"
string(2) "dt"
=====
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>