[php-src] PR #23102: Enforce zero arity in apache_get_version() and apache_get_modules()

From: Date: Fri, 07 Aug 2026 14:21:21 +0000
Subject: [php-src] PR #23102: Enforce zero arity in apache_get_version() and apache_get_modules()
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-37617@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/23102 Author: lacatoire sapi/apache2handler/php_functions.stub.php declares both functions with no parameters: ```php function apache_get_version(): string|false {} function apache_get_modules(): array {} ``` The generated arginfo agrees and ReflectionFunction::getNumberOfParameters() returns 0, but neither implementation calls ZEND_PARSE_PARAMETERS_NONE(), so the declared arity is never enforced and extra positional arguments are silently accepted. Served by php:8.4-apache and php:8.5-apache (PHP 8.4.24 and 8.5.9, Apache 2.4.68), identical on both: ```php <?php var_dump(apache_get_version(1, 2, 3)); var_dump(count(apache_get_modules(1, 2))); var_dump(apache_request_headers(1)); ``` ``` string(22) "Apache/2.4.68 (Debian)" int(28) Fatal error: Uncaught ArgumentCountError: apache_request_headers() expects exactly 0 arguments, 1 given ``` The first two calls should throw like the third one. Every other zero-arity function of the same SAPI does enforce its arity, because it calls the macro: apache_request_headers() (php_functions.c:167), apache_response_headers() (php_functions.c:188), and getallheaders() through its alias. The litespeed implementation of the same function name, PHP_FUNCTION(apache_get_modules) in sapi/litespeed/lsapi_main.c:1710, also opens with ZEND_PARSE_PARAMETERS_NONE(), so the two SAPIs currently disagree on whether apache_get_modules(1) is an error. Only the positional path is affected: named arguments are rejected by arginfo already, apache_get_version(x: 1) throws Error: Unknown named parameter $x. No stub or arginfo change is needed, the stub already says zero parameters. Targeting master rather than a stable branch, since the change turns a silently accepted call into an ArgumentCountError. Sources: - 11a95749b1 "Convert more zend_parse_parameters_none() to fast ZPP" converted the existing call sites in this file; these two never had one, so the sweep did not reach them.

« previous php.git-pulls (#37617) next »