Skip to content

Regression: CachingIterator::setFlags() clears CALL_TOSTRING — Zend InvalidArgumentException (ext/spl/spl_iterators.c) #24252

Description

@PurHur

Category

Regression · php-src-strict · stdlib (SPL iterators)

Problem

When a CachingIterator was constructed with CachingIterator::CALL_TOSTRING (or the flag is set), php-src refuses to clear that flag via setFlags(): it throws InvalidArgumentException with message Unsetting flag CALL_TO_STRING is not possible. On VM (2026-07-28), setFlags(CachingIterator::FULL_CACHE) and setFlags(0) succeed and drop CALL_TOSTRING.

Repro Zend 8.2 VM (2026-07-28)
construct with CALL_TOSTRING, then setFlags(FULL_CACHE) InvalidArgumentException flags become 256
then setFlags(0) same exception flags become 0

php-src reference

PHP implementation target

  • ext/spl/ CachingIterator setFlags implementation (PHP) — reject clearing CALL_TOSTRING like php-src
  • Keep construct/getFlags parity; no new C runtime logic

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_cachingiterator_setflags_call_tostring.php'
<?php
$it = new CachingIterator(new ArrayIterator([1]), CachingIterator::CALL_TOSTRING);
$it->setFlags(CachingIterator::FULL_CACHE); // Zend: InvalidArgumentException

Done when

  • setFlags that would clear CALL_TOSTRING throws InvalidArgumentException with Zend message
  • Flags unchanged after the rejected call
  • Compliance or test/repro/ guard
  • php-src-strict; no php-compiler-strict shortcut

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