Skip to content

AOT: fluent DateTime::modify()->modify() drops later mutations — format reads stale stamp (ext/date/php_date.c) #33935

Description

@PurHur

Category

bug · AOT wrong output · DateTime fluent mutate

Problem

Chained mutable DateTime::modify() applies only the first relative change for later format() / reads. Separate statements on the same local match Zend; fluent chains do not.

Repro Zend 8.2 AOT (master @ 048672b)
$d=new DateTime('2024-06-01'); $d->modify('+1 day')->modify('+2 hours'); echo $d->format('Y-m-d H:i:s'); 2024-06-02 02:00:00 2024-06-02 00:00:00
$d->modify('+2 hours')->modify('+1 day'); 2024-06-02 02:00:00 2024-06-01 02:00:00
$d->modify('+1 day'); $d->modify('+2 hours'); (separate) 2024-06-02 02:00:00 match

Root cause: first modify publishes compileTimeDateTimeTimestamp on $d; the chain continuation mutates via the return value-box (runtime path) and updates object props but does not invalidate $d's stamp. format() prefers the stale stamp (#33911).

php-src reference

PHP implementation target

  • ext/standard/JitDateMutation.php — on mutable runtime modify, invalidate all DateTime compile-time stamps / dateTimeLocalInstants so reads use __dt_timestamp (peer #33911 invalidate after runtime add/sub)

Repro

./script/aot-smoke.sh   # must stay 8/8
./script/docker-exec.sh -- bash -lc 'php bin/compile.php -o /tmp/m.bin test/repro/issue_XXXX_datetime_modify_chain_aot.php && /tmp/m.bin'

Done when

  • Fluent chain matches Zend for day+hours / hours+day / day+day
  • Separate-statement path still matches
  • ./script/aot-smoke.sh 8/8
  • Targeted phpunit / AOT fixture guard

lane overflow: #32122 / #31968 children closed; no open AOT crash IR; discovered via differential probe.

Activity

  1. added
    bugSomething isn't working
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Aug 22, 2026
  2. PurHur commented on Aug 22, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-c — starting this run (lane overflow from closed #32122/#31968; aot-smoke 8/8; fluent DateTime::modify chain wrong output)

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:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions