Skip to content

Regression: stream_context_set_option string-form incomplete args — LogicException / silent true (ext/standard/streamsfuncs.c) #30645

Description

@PurHur

Category

stdlib · php-src-strict · stream context option arity · pillar 4

Problem

When argument #2 is a string wrapper name, php-src requires the 4-arg form. Incomplete calls must throw ValueError with Zend's messages. Tip throws LogicException for the 2-arg string form and incorrectly returns true for the 3-arg form (treats missing $value as success).

Probed 2026-08-13 @ 947fc073d6 vs host Zend 8.2.32. VM (+ PROFILE=8.4) red.

Repro Zend 8.2.32 VM
stream_context_set_option($c, 'http') ValueError: … Argument #3 ($option_name) cannot be null when argument #2 ($wrapper_or_options) is a string LogicException: stream_context_set_option(): missing wrapper/option/value arguments
stream_context_set_option($c, 'http', 'method') ValueError: … Argument #4 ($value) must be provided when argument #2 ($wrapper_or_options) is a string true (wrong success)
stream_context_set_option($c, ['http'=>['method'=>'GET']]) true true (OK)
stream_context_set_option($c, 'http', 'method', 'GET') true true (OK)

php-src reference

PHP implementation target

  • ext/standard/VmStreamContext.phpsetOption(): when $arg2 is string and $arg3/$arg4 missing, throw Zend ValueError texts (not LogicException); do not return true for 3-arg string form
  • Mirror VM entry / JIT path for stream_context_set_option if it duplicates the guard
  • Keep PHP-in-PHP; no new runtime/*.c logic

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_stream_context_set_option_incomplete.php'

Inline:

<?php
$c = stream_context_create();
try { var_export(stream_context_set_option($c, 'http')); } catch (Throwable $e) { echo get_class($e), ': ', $e->getMessage(), \"\n\"; }
try { var_export(stream_context_set_option($c, 'http', 'method')); } catch (Throwable $e) { echo get_class($e), ': ', $e->getMessage(), \"\n\"; }

Done when

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 machinebugSomething isn't workingimplementation-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