Repository navigation
[6.x] Laravel Octane support - #20641
Merged
Merged
Conversation
Reset Craft's request state between operations on a long-lived worker: - Singletons resolve request-scoped services per use, instead of keeping the first request's, such as Elements' placeholder elements, which exposed a previewed draft to later anonymous requests. - The `app` root view composer is registered once at boot, rather than piling up per request and dropping the CP's legacy asset bundles. - A listener resets static memos, reloads the project config and timezone, re-registers project config routes, and restores the view finder before each Octane request, task, and tick. The stdio MCP server runs the same reset before each request. - Asset::displayName() is no longer memoized across languages. Adds laravel/octane as a dev dependency, for the Octane worker tests. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d08b-472f-757e-8aa8-33f56bf5aab8 Co-authored-by: Amp <amp@ampcode.com>
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
Amp-Thread-ID: https://ampcode.com/threads/T-01a1d08b-472f-757e-8aa8-33f56bf5aab8 Co-authored-by: Amp <amp@ampcode.com>
Contributor
|
Thank you!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes Craft safe to run on Laravel Octane (Swoole and RoadRunner), where one worker boots the app once and serves many requests.
State that outlived a request, and how it's reset now:
Singletons that held request-scoped services now resolve them per use:
laravel/octaneis added as a dev dependency only; Craft references its events by class name, so sites without Octane are unaffected.Breaking for subclasses:
Elements::__construct()no longer takesElementPlaceholders.Evidence
Differential run, Octane vs.
php -S: 1046 identical request sequences (CP pages, three-language site, admin and non-admin users, preview tokens, GraphQL tokens, saves) against two copies of the same seeded workbench.The remaining body diffs are random by nature: encrypted values, CSRF/preview tokens, freshly generated UUIDs, and the env-var autocomplete list (Octane's own variables).
Other checks:
Before / after, from
tests/Feature/Http/OctaneWorkerTest.php(several requests through oneFakeWorker):Before / after, from
tests/Feature/Mcp/StdioTest.php:composer cipasses.