Skip to content

Regression: http_build_query() 4th encoding_type arg — data operand null (ext/standard/http.c) #12008

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

http_build_query() with all four positional parameters mis-binds operands on the VM when $encoding_type (PHP_QUERY_RFC1738 / PHP_QUERY_RFC3986) is supplied. Zend returns the encoded query string; VM throws TypeError: Argument #1 ($data) must be of type array, null given even though the first argument is an inline array literal.

http_build_query(['a' => ['x', 'y']], '', '&', PHP_QUERY_RFC1738);
// Zend: a%5B0%5D=x&a%5B1%5D=y
// VM: TypeError on $data (null)

Distinct from #11300 (nested literal LogicException without 4th arg) and #8733 (enum value encoding).

php-src reference

PHP implementation today

  • ext/standard/http_build_query.php — VmArray::requireArrayParam($frame->calledArgs[0], …)
  • ext/standard/VmHttpBuildQuery.php — RFC1738/3986 encoding

Repro

test/repro/maintainer_gap_http_build_query_encoding_type.php

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_http_build_query_encoding_type.php
./script/docker-exec.sh -- php test/repro/maintainer_gap_http_build_query_encoding_type.php
Runtime Output
Zend ok
VM TypeError: http_build_query(): Argument #1 ($data) must be of type array, null given

Implementation hints (PHP-in-PHP)

  • Fix VM builtin optional-parameter slotting for 3rd/4th args (numeric_prefix, arg_separator, encoding_type)
  • Verify named encoding_type: path once positional call is fixed
  • JIT/AOT: ext/standard/JitHttpBuildQuery.php / HttpBuildQueryJitHelper.php

Done when

  • Repro prints ok on VM for PHP_QUERY_RFC1738 and PHP_QUERY_RFC3986
  • 1–3 arg forms unchanged
  • Compliance guard committed

Refs #1492, #11300, #4781.

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 26, 2026
  2. PurHur commented on Jun 26, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #12007, #12008, #12009)

  3. PurHur commented on Jun 26, 2026

    @PurHur
    OwnerAuthor

    Repro test/repro/maintainer_gap_http_build_query_encoding_type.php already prints ok on current master (VM + Zend). No code change needed — closing as non-reproducible regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions