Problem/Motivation

FrankenPHP workers reuse the kernel and container across requests. ThemeManager::getActiveTheme() retains the previous request’s theme across requests, so if you navigate from an admin theme page to a regular theme page, things break. Request termination also

Another problem is that request termination also empties the runtime theme collectors through CacheCollector::destruct(), but Registry::destruct() retains them. Later requests reuse those collectors, so previously registered theme hooks are reported as missing.

Steps to reproduce

  1. Configure a default theme and a different administration theme.
  2. Render an uncached administration page, then terminate the request.
  3. Using the same kernel and container, request an uncached public page. The active theme remains the administration theme.
  4. Check a previously registered hook through Registry::getRuntime(). The retained collector reports it missing.

Proposed resolution

In DrupalKernel::handle(), reset the initialized theme manager before each main request. Preserve the active theme for subrequests. Release runtime collectors before destructing them so subsequent requests construct fresh collectors.

User interface changes

None.

API changes

None.

Data model changes

None.

AI disclosure: I used AI to help prepare the IS and MR (Astra and Opus 5.5).

Issue fork drupal-3626324

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Status: Active » Needs work

I am submitting a draft MR to fix this but it needs a test, and I'd also like confirmation that this is the right direction for a fix.

ptmkenny’s picture

Issue summary: View changes
nicxvan’s picture