Closed lisandro-compucorp closed 2 years ago
@lisandro-compucorp this issue appears to be happening at other times then just when you clear DB cache. Can you confirm this PR fixes it in other situations also?
@lisandro-compucorp this issue appears to be happening at other times then just when you clear DB cache. Can you confirm this PR fixes it in other situations also?
Yes @jamienovick this solves those problems also. I added an extra Note on the PR description, on "Before" section, explaining why.
Overview
This PR solves the theme problem that appears after clearing the DB Cache
Before
The problem observed consists of the Shoreditch theme not loading correctly at some intervals, but that situation gets solved after refreshing the page. This is an example of how the interface looks: The error can be reproduced by executing the Job that clears the DB Cache: Note The job usually runs by a console, not using the "Execute now" in the UI as I did on the demo, then the page refresh that we are seeing is not performed. This causes that the next user to access the site after the cron runs in the background sees the error on the theme.
After
The error after clearing DB Cache does not appear anymore:
Technical Details
The function
_shoreditch_isActive
depends on Civi::service('themes')->getActiveThemeKey() to determine if it is active. This is, in turn, depending on DrupalBase method for detecting if the path corresponds to a frontend or backend theme:Since the first moment after the Db Cache clears the menu is empty, the condition of the mentioned method:
Returns true (since
empty($item) === TRUE
).For solving this we have two options:
In this PR I go for the second option, which is easier and acceptable in performance terms.
Backstop JS Report