[php-src] Issue #20749: `DOCUMENT_ROOT` from environment in cli is not propagated to $_SERVER['DOCUMENT_ROOT']
[email protected] (ivan-u7n)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
Issue: https://github.com/php/php-src/issues/20749
Author: ivan-u7n
### Description
The following code:
```sh
DOCUMENT_ROOT=/test php -r 'var_dump($_SERVER["DOCUMENT_ROOT"]);'
```
Resulted in this output:
```
string(0) ""
```
But I expected this output instead:
```
string(5) "/test"
```
with a file the out is the same
I think the culprit is https://github.com/php/php-src/blob/42f994cd05da353c93cd65775026859f664289a3/sapi/cli/php_cli.c#L344 as the only mention of `DOCUMENT_ROOT` for php-cli
### PHP Version
```plain
PHP 8.4.15 (cli) (built: Nov 20 2025 19:00:52) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.15, Copyright (c) Zend Technologies
with Zend OPcache v8.4.15, Copyright (c), by Zend Technologies
```
### Operating System
_No response_