Problem/Motivation
The ActiveTheme objects contain an ActiveTheme object for each base theme - although this is never really used. This makes the theme.active_theme.seven cache entry much larger than necessary.
Proposed resolution
Reduce the amount of stuff stored in the ActiveTheme class by deprecating the ability to store ActiveTheme objects for base themes and store the extension object instead.
Also this is likely to be a perfomance boost because
Before
select length(data) from cache_bootstrap where cid = 'theme.active_theme.seven';
+--------------+
| length(data) |
+--------------+
| 90370 |
+--------------+
After
mysql> select length(data) from cache_bootstrap where cid = 'theme.active_theme.seven';
+--------------+
| length(data) |
+--------------+
| 43590 |
+--------------+
Here's a profile of cold caches showing the improvement from storing less stuff and doing less stuff - https://blackfire.io/profiles/compare/e21a0d28-9f1e-4488-b094-f78bec83b8...
Here's a profile of warm caches showing the improved memory usage - https://blackfire.io/profiles/compare/a4045574-796a-421b-a518-a49369d63c...
Remaining tasks
User interface changes
None
API changes
\Drupal\Core\Theme\ActiveTheme::getBaseThemes() is deprecated. There is no direct replacement. Base theme extension objects can be retrieved from the active theme using the new \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() method. In order to get active theme representations of any theme you can use \Drupal::service('theme.initialization')->getActiveThemeByName($theme_name);
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3020157-2.patch | 14.27 KB | alexpott |
Comments
Comment #2
alexpottHere's a patch copied over from #2701829: Extension objects should not implement \Serializable
Comment #3
alexpottOpened an issue to deal with engine-less themes - #3020248: Remove potential support for engine-less themes
Comment #4
jibranAlready reviewed and RTBC in #2701829-93: Extension objects should not implement \Serializable.
Comment #5
alexpottComment #6
catchCommitted 63556cd and pushed to 8.7.x. Thanks!
Comment #9
mglamanThe CR is still a draft: https://www.drupal.org/node/3019948
It took me a bit to grok that CR to understand that this has nothing to do with
base_themeand was for the internal tracking of a theme's base themes. Probably because I discovered this in code first versus the CR.Comment #10
quietone commentedpublished the change record