Skip to content

Regression: stream_filter_register() non-php_user_filter class — returns false, Zend returns true + E_WARNING (ext/standard/streams.c) #13733

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

When stream_filter_register() is called with a class that does not extend php_user_filter, Zend emits E_WARNING (class must extend php_user_filter) and returns true — the filter name is registered and appears in stream_get_filters(). The VM returns false, does not register the name, and subsequent stream_filter_append() is a no-op.

This diverges from php-src stream user-filter registration semantics and breaks code that checks the boolean return while still expecting Zend’s warning side effect.

php-src reference

Repro (verified 2026-06-29)

php test/repro/stream_filter_register_invalid_class_return.php
php bin/vm.php test/repro/stream_filter_register_invalid_class_return.php
Step Zend PHP 8.2+ VM today
stream_filter_register($name, BadFilter::class) true + E_WARNING false + E_WARNING
in_array($name, stream_get_filters()) yes no
stream_filter_append($fp, $name) after register filter runs (may warn on brigade) no-op (stream unchanged)

Minimal:

class BadFilter {
    public function filter($in, $out, &$consumed, $closing) {
        return PSFS_PASS_ON;
    }
}
$name = 'bad.' . getmypid();
$ok = stream_filter_register($name, BadFilter::class);
// Zend: $ok === true; VM: $ok === false

Scope (PHP-in-PHP first)

Layer Path
VM ext/standard/stream_filter_register.php — match php-src return + registry
Filter append ensure append can resolve user filters registered with Zend semantics
Tests test/compliance/cases/stdlib/stream_filter_register_invalid_class.phpt

Done when (php-src-strict)

  • Invalid class: E_WARNING + return true like Zend
  • Filter name listed in stream_get_filters() after register attempt
  • Valid extends php_user_filter path unchanged (test/repro/maintainer_gap_php_user_filter_class.php stays green)
  • ./script/ci-fast.sh --filter stream_filter_register green

Verification

php test/repro/stream_filter_register_invalid_class_return.php
php bin/vm.php test/repro/stream_filter_register_invalid_class_return.php

Links

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 29, 2026
  2. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #13733, #13734)

  3. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Merged via #13737. VM repro test/repro/stream_filter_register_invalid_class_return.php prints ok=true / in_list=true; AOT lint green on repro.

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