Skip to content

FrankenPHP: persist some core services across requests - #64104

Draft
CarlSchwan wants to merge 10 commits into
masterfrom
carl/PersistAcrossRequests
Draft

CarlSchwan wants to merge 10 commits into
masterfrom
carl/PersistAcrossRequests

Conversation

@CarlSchwan

Copy link
Copy Markdown
Member
  • Resolves: #

Summary

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@CarlSchwan CarlSchwan self-assigned this Sep 7, 2026
@CarlSchwan
CarlSchwan requested a review from a team as a code owner September 7, 2026 14:31
@CarlSchwan
CarlSchwan requested review from Altahrim, leftybournes, provokateurin and salmart-dev and removed request for a team September 7, 2026 14:31
@CarlSchwan
CarlSchwan marked this pull request as draft September 7, 2026 14:37
Comment thread lib/private/Route/Router.php Outdated
Comment on lines +560 to +576
$application = $this->container->get($applicationClassName);
// Always the current container: this Router instance may outlive the request that built it.
$application = \OCP\Server::get($applicationClassName);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit ugly.
I think I would prefer as a first step to keep the containers across requests, but empty their stored services completely.
And then as a second step make it possible to let some classes stay in the container across requests.

This would avoid the current dance where objects get stored in a static array and then back to the container.

Comment thread Caddyfile
}

localhost {
franken.local {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be pushed I guess

Used to mark a service as reusable between request when running franken
php.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Add SimpleContainer::resetForNextRequest(), which evicts non-persistent
services instead of rebuilding the whole container every request.
Also move connectDispatcher() into boot(), since IEventDispatcher
isn't itself persisted.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
updateType()/updateSensitive()/updateLazy() and Installer's shipped-app
install path never invalidated PersistentServiceGroup::Config.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
…dator

Avoids rebuilding it on every generation check.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Refresh per-request state (context, IAppManager, IEventLogger) on
each request. Also check isEnabledForAnyone() instead of
isEnabledForUser(): $root is now shared across requests, so a
per-user decision would leak into other users' requests.

Assisted-by: ClaudeCode:claude-sonnet-5
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
…ted container

Makes its dependency explicit and testable.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
@CarlSchwan
CarlSchwan force-pushed the carl/PersistAcrossRequests branch from ebef784 to 00fa6dc Compare September 16, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants