Skip to content

Stdlib: parse_str() — reject one-argument form in all scopes (PHP 8+ ext/standard/basic_functions.c) #4050

Description

@PurHur

Category

stdlib / runtime

Problem

Since PHP 8.0, parse_str() requires two arguments ($encoded_string, &$result). The one-argument form that imported variables into the local symbol table was removed.

This compiler still accepts one argument at main-script scope and imports query vars into the caller frame (ext/standard/parse_str.php + VmScope::requireMainScriptForParseStrOneArg). Zend throws ArgumentCountError everywhere, including top-level scripts.

php-src reference

Repro (today)

test/repro-maintainer/parse_str_function_scope.php:

./script/docker-exec.sh -- bash -lc 'php test/repro-maintainer/parse_str_function_scope.php'
# ArgumentCountError on line 11 (script-level one-arg)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro-maintainer/parse_str_function_scope.php'
# y:home:y:3  ← script-level one-arg still imports $route/$page (wrong)

Inline check:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "parse_str(\"x=1\"); echo isset(\$x)?\$x:\"no\";"'
# 1  ← should throw ArgumentCountError

Scope (this repo)

Module Path
VM ext/standard/parse_str.php, ext/standard/VmScope.php, ext/standard/VmParseStr.php
JIT ext/standard/JitParseStr.php — remove main-script one-arg exception
Tests update test/repro-maintainer/parse_str_function_scope.php; add compliance PHPT

Done when

  • One-arg parse_str() throws catchable ArgumentCountError in functions and at main script scope (VM/JIT/AOT)
  • Two-arg form unchanged: populates $result array and returns true
  • ./script/ci-fast.sh --filter parse_str green

Related

Activity

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions