Skip to content

Stdlib: stream_bucket_make_writeable() / stream_bucket_append() — filter brigades (streamsfuncs.c) #4688

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Filtered stream pipelines in php-src use stream_bucket_make_writeable(), stream_bucket_append(), and stream_bucket_new() to move buckets between brigades. User-defined php://filter chains and custom filters call these after #3494 / stream filters land.

This compiler implements core fopen/fread/fwrite but not the bucket API — function_exists('stream_bucket_make_writeable') is false on VM.

php-src reference

Repro A — existence

<?php
var_export(function_exists('stream_bucket_make_writeable'));
var_export(function_exists('stream_bucket_append'));
var_export(function_exists('stream_bucket_new'));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro_stream_bucket_exists.php      # true,true,true
php bin/vm.php repro_stream_bucket_exists.php  # false,false,false
'

Repro B — brigade mutation (after filters exist)

Port minimal php-src test: read via php://filter/read=string.toupper and inspect bucket objects when filter callbacks invoke bucket helpers (depends on #9047 stream_filter_* — can stub VM-only first).

Scope (this repo)

Layer Path
VM stream layer lib/VM/ stream wrappers + brigade objects
Builtins ext/standard/stream_bucket_make_writeable.php, stream_bucket_append.php, stream_bucket_new.php, Module.php
PHP-in-PHP bucket structs as PHP classes, not runtime/*.c tables
JIT defer (VM-first); file follow-up if LLVM stream path needs buckets
Tests test/compliance/cases/stdlib/stream_bucket_*.phpt

Done when

  • Repro A: all three function_exists true on VM
  • stream_bucket_make_writeable($brigade) returns bucket object or false like Zend
  • stream_bucket_append($brigade, $bucket) mutates brigade; refcount semantics per php-src
  • At least one filter pipeline script runs without undefined-function fatal
  • script/capability-matrix.php regenerated

Links

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