mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
🐛 Reactivate theme on override + cache clear (#7368)
closes #7350 - When the active theme is overridden, ensure that the activateTheme middleware gets called by removing the `req.app.activeTheme` value. - Additionally, ensure that the full cache is invalidated
This commit is contained in:
parent
98a17d5116
commit
4287e0e78b
@ -43,6 +43,10 @@ init = function init() {
|
||||
return settings.updateSettingsCache();
|
||||
};
|
||||
|
||||
function isActiveThemeOverride(method, endpoint, result) {
|
||||
return method === 'POST' && endpoint === 'themes' && result.themes && result.themes[0] && result.themes[0].active === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### Cache Invalidation Header
|
||||
* Calculate the header string for the X-Cache-Invalidate: header.
|
||||
@ -67,7 +71,12 @@ cacheInvalidationHeader = function cacheInvalidationHeader(req, result) {
|
||||
hasStatusChanged,
|
||||
wasPublishedUpdated;
|
||||
|
||||
if (['POST', 'PUT', 'DELETE'].indexOf(method) > -1) {
|
||||
if (isActiveThemeOverride(method, endpoint, result)) {
|
||||
// Special case for if we're overwriting an active theme
|
||||
// @TODO: remove this crazy DIRTY HORRIBLE HACK
|
||||
req.app.set('activeTheme', null);
|
||||
return INVALIDATE_ALL;
|
||||
} else if (['POST', 'PUT', 'DELETE'].indexOf(method) > -1) {
|
||||
if (endpoint === 'schedules' && subdir === 'posts') {
|
||||
return INVALIDATE_ALL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user