Skip to content

[6.x] Reset remaining CP statics between requests in long-lived processes - #15441

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
petemolinero:fix/clear-state-cp-statics
Sep 11, 2026
Merged

[6.x] Reset remaining CP statics between requests in long-lived processes#15441
jasonvarga merged 1 commit into
statamic:6.xfrom
petemolinero:fix/clear-state-cp-statics

Conversation

@petemolinero

@petemolinero petemolinero commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Under long-lived processes (e.g. Laravel Octane), the process serves many requests, and we need to be super careful that data doesn't leak between requests. Most of that is already taken care of by the ClearState listener, which resets Antlers runtime state, stateful tags, and the URL cache after every request — but $jsonVariables, $isRenderingCpException, and breadcrumbs still leaked. This PR closes those gaps.

How it solves request-to-request leakage

  • Restoring $jsonVariables to a boot-time snapshot - $jsonVariables can't just be cleared — boot-time registrations must survive. So we snapshot it once, at the start of the process's first request (the one moment where all boot-time registrations exist and no request-time ones do), and revert to that snapshot after every response.
  • Resetting $isRenderingCpException - it's set to true when a CP error page renders and never set back, so one CP error would degrade every later CP response from the process. Now it's set back to false after every response.
  • Clearing breadcrumbs - Breadcrumbs::$pushed only ever accumulates, so one request's breadcrumbs would show up on every later one. Now it's emptied after every response.

Like the earlier fixes in this class (#9240, #9241, #11283), this is unconditional: it's behavior-neutral under PHP-FPM, since the resets run after the response is built and the process exits right after anyway (and with no snapshot taken — console, queue — the restore is a no-op).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@petemolinero
petemolinero force-pushed the fix/clear-state-cp-statics branch from 70b8f4b to 1b2c6f6 Compare September 10, 2026 15:20
@jasonvarga
jasonvarga merged commit 06bde61 into statamic:6.x Sep 11, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants