-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Directory cache is not invalidated after saving page #3152
Comments
Here are a couple of utility functions I added to core-service-manager as our workaround. /**
* Call this function, after saving a page, if needing to redirect back to the page's admin.
*/
public function updateAdminCache(): void
{
if ($this->gravVersionMatches('1.7.0-rc.0', '>=')) {
Cache::clearCache('invalidate');
$flex = $this->grav['flex'];
$directory = $flex->getDirectory('pages');
$directory->clearCache();
}
}
/**
* A workaround that saves a page and then updates relevant Admin plugin caches.
* @param Page $page
*/
public function save(Page $page)
{
$page->save();
$this->updateAdminCache();
} Invoke it like this: $this->grav['core-service-util']->save($myPage); I am currently adding methods to CSM to help write code blocks to run under different versions of Grav, GravAdmin, and PHP, so this will be updated to call the proper code depending on the installation. |
BTW, you cannot have You should be using |
Yes this is legacy code and I am not currently using |
I took a quick look; saving the old I think we need to add some code to signal the another party that there has been a change. |
@Flamenco Should be fixed now, the old code should work. |
This code does not work.
The redirect page shows the following message, although the page is saved and served:
After several seconds and a page refresh, the error goes away. It also goes away by clearing the cache in the admin.
This code works after calling
$directory->clearCache();
I would like to simply call the following and be isolated from the implementation.
The text was updated successfully, but these errors were encountered: