Category
stdlib
Problem
PHP 8.4 adds request_parse_body(string $body, array $options = []): array — parse application/x-www-form-urlencoded and multipart/form-data payloads without populating $_POST / $_FILES. CLI tools, unit tests, and middleware use it to inspect raw HTTP bodies.
This compiler has no such function (function_exists('request_parse_body') → false). Multipart support exists for CGI (lib/Web/ populates $_POST/$_FILES) but not as a standalone API.
PHP 8.4 also adds RequestParseBodyException (extends Exception) for malformed bodies — must be registered before the function ships.
php-src reference
Repro (undefined function today)
test/repro-maintainer/maintainer_request_parse_body.php:
<?php
declare(strict_types=1);
// URL-encoded
$body = "a=1&b=two";
$result = request_parse_body($body);
var_export($result);
echo "\n";
// Multipart (minimal)
$boundary = '----WebKitFormBoundary7MA4YWxkTrZu0gW';
$multipart = "--$boundary\r\n"
. "Content-Disposition: form-data; name=\"field\"\r\n\r\n"
. "value\r\n"
. "--$boundary--\r\n";
$result2 = request_parse_body($multipart, ['content_type' => "multipart/form-data; boundary=$boundary"]);
var_export($result2['post']['field'] ?? 'missing');
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/maintainer_request_parse_body.php 2>&1 | head -5 # Zend 8.4+
php bin/vm.php test/repro-maintainer/maintainer_request_parse_body.php 2>&1 | head -2
'
| Runtime |
Result |
| Zend PHP 8.4+ |
array ('post' => array ('a' => '1', 'b' => 'two'), 'files' => array ()) + multipart value |
bin/vm.php |
Call to undefined function request_parse_body() |
Exception class probe
test/repro-maintainer/parity_request_parse_body_exception.php (Zend 8.4+ only):
<?php
declare(strict_types=1);
var_dump(class_exists('RequestParseBodyException'));
try {
throw new RequestParseBodyException('malformed body');
} catch (RequestParseBodyException $e) {
echo 'caught:', $e->getMessage(), "\n";
}
On Zend 8.4+: class_exists true and typed catch works. VM must match when implementing #5965 (do not ship function without exception class).
Scope (this repo)
| Module |
Path |
| Parser core |
reuse/adapt lib/Web/MultipartParser.php → shared VmHttpBodyParser |
| Builtin |
ext/standard/request_parse_body.php |
| Exception |
register RequestParseBodyException in ext/standard/ThrowableManifest.php (or sibling) |
| Registration |
ext/standard/Module.php |
| Options |
content_type, max_parts, max_input_vars parity subset per php-src |
| Tests |
test/compliance/cases/stdlib/request_parse_body_urlencoded.phpt, request_parse_body_multipart.phpt, request_parse_body_exception.phpt |
| JIT/AOT |
VM-first v1 |
PHP-in-PHP: parser logic in ext/ + lib/Web/; C only for unavoidable platform I/O (none for string-in API).
Done when (php-src-strict)
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter request_parse_body'
Related
Category
stdlibProblem
PHP 8.4 adds
request_parse_body(string $body, array $options = []): array— parseapplication/x-www-form-urlencodedandmultipart/form-datapayloads without populating$_POST/$_FILES. CLI tools, unit tests, and middleware use it to inspect raw HTTP bodies.This compiler has no such function (
function_exists('request_parse_body')→ false). Multipart support exists for CGI (lib/Web/populates$_POST/$_FILES) but not as a standalone API.PHP 8.4 also adds
RequestParseBodyException(extendsException) for malformed bodies — must be registered before the function ships.php-src reference
ext/standard/http.c—PHP_FUNCTION(request_parse_body)ext/standard/basic_functions.stub.php—RequestParseBodyExceptionmain/php_variables.c—php_parse_input_data,php_handle_form_dataRepro (undefined function today)
test/repro-maintainer/maintainer_request_parse_body.php:array ('post' => array ('a' => '1', 'b' => 'two'), 'files' => array ())+ multipartvaluebin/vm.phpCall to undefined function request_parse_body()Exception class probe
test/repro-maintainer/parity_request_parse_body_exception.php(Zend 8.4+ only):On Zend 8.4+:
class_existstrue and typed catch works. VM must match when implementing #5965 (do not ship function without exception class).Scope (this repo)
lib/Web/MultipartParser.php→ sharedVmHttpBodyParserext/standard/request_parse_body.phpRequestParseBodyExceptioninext/standard/ThrowableManifest.php(or sibling)ext/standard/Module.phpcontent_type,max_parts,max_input_varsparity subset per php-srctest/compliance/cases/stdlib/request_parse_body_urlencoded.phpt,request_parse_body_multipart.phpt,request_parse_body_exception.phptPHP-in-PHP: parser logic in
ext/+lib/Web/; C only for unavoidable platform I/O (none for string-in API).Done when (php-src-strict)
function_exists('request_parse_body')true; URL-encoded repro matches Zend return shapepost+filesnested arrays like ZendRequestParseBodyExceptionregistered; malformed body throws it (not genericException)content_type/ malformed body errors match Zend (ValueError/RequestParseBodyExceptionper php-src)./script/ci-fast.sh --filter request_parse_bodygreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter request_parse_body'Related
$_FILES(reuse parser)