Set cache key uniquely for admin to not colide with site.

This commit is contained in:
Andy Miller
2016-04-14 15:28:48 -06:00
parent 3f81adea0f
commit cdf4a4b0e8
2 changed files with 9 additions and 1 deletions

View File

@@ -16,6 +16,7 @@
* The default Grav theme has been tweaked and in many places completely rewritten to ensure that it's as flexible as possible. The primary reason for this was to ensure theming and customization compatibility for the upcoming Admin Pro plugin, but a key benefit includes greatly improved mobile compatibility.
* Lists can now accept a custom button label with the 'btnLabel' property
* After login to Admin, redirect to the original URL called
* Admin now has an unique cache key compared to the 'site' so pages can be cached independently
1. [](#bugfix)
* Clear cache after adding a new folder

View File

@@ -73,7 +73,7 @@ class AdminPlugin extends Plugin
{
if (!Grav::instance()['config']->get('plugins.admin-pro.enabled')) {
return [
'onPluginsInitialized' => [['setup', 100000], ['onPluginsInitialized', 1000]],
'onPluginsInitialized' => [['setup', 100000], ['onPluginsInitialized', 1001]],
'onShutdown' => ['onShutdown', 1000],
'onFormProcessed' => ['onFormProcessed', 0],
'onAdminDashboard' => ['onAdminDashboard', 0],
@@ -243,6 +243,13 @@ class AdminPlugin extends Plugin
// Only activate admin if we're inside the admin path.
if ($this->active) {
// Have a unique Admin-only Cache key
if (method_exists($this->grav['cache'], 'setKey')){
$cache = $this->grav['cache'];
$cache_key = $cache->getKey();
$cache->setKey($cache_key . '$');
}
// Turn on Twig autoescaping
if (method_exists($this->grav['twig'], 'setAutoescape')) {
$this->grav['twig']->setAutoescape(true);