Skip to content

Commit

Permalink
馃悰 Reactivate theme on override + cache clear (#7368)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ErisDS authored and kirrg001 committed Sep 14, 2016
1 parent 98a17d5 commit 4287e0e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/server/api/index.js
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down

0 comments on commit 4287e0e

Please sign in to comment.