Skip to content

AdminThemeUikit loads theme CSS from wrong module copy after switching module file #2326

Description

@matjazpotocnik

When both core and site copies of AdminThemeUikit exist, switching the active module file can produce mixed asset paths.

Steps to reproduce

Copy AdminThemeUikit to /site/modules/.
Select the /site copy and load an admin page.
Switch to the /wire copy.
Inspect loaded stylesheets.

Actual result

/wire/modules/AdminTheme/AdminThemeUikit/uikit-pw/pw.min.css
/site/modules/AdminThemeUikit/themes/default/admin-custom.css
/site/modules/AdminThemeUikit/themes/default/admin.css

Expected result

All assets should load from the currently selected module copy.

getThemeInfo() stores theme paths and URLs in the session under themeInfos. Because both module copies share the same class name, switching files reuses paths cached for the previously active copy.

A possible fix is to store the module path with the cached theme information and rebuild the cache when $config->paths($this) changes:

 $session = $this->wire()->session;
+$config = $this->wire()->config;
+$thisPath = $config->paths($this);
 $themeInfos = $session->getFor($this, 'themeInfos');
+if($session->getFor($this, 'themeInfosPath') !== $thisPath) $themeInfos = [];

When rebuilding:

 $session->setFor($this, 'themeInfos', $themeInfos);
+$session->setFor($this, 'themeInfosPath', $thisPath);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions