fix(cache-on-save): invalidate page index on save so new entries are editable

deleteAll() only clears the Doctrine store; the page-tree index is keyed on
md5(dirs + folderHash + config->checksum() + lang) (Pages::buildRegularPages).
With cache.check.method:folder a freshly-created entry could survive in that
index and stay invisible to GET /api/v1/pages{route} (404), so opening a
just-posted entry for editing showed "this entry no longer exists" ~2/3 of the
time. Add Cache::invalidateCache() (touches system.yaml -> bumps config
checksum) so the index key changes and the tree rebuilds next request. Chosen
over clearCache('standard'), which would nuke compiled Twig + assets on every
post. Fixes the create->edit round-trip (Playwright ES1) and the DEL1 flake.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mpdu3Dt1iVoozHwAMyjrbn
This commit is contained in:
2026-07-05 23:42:11 +02:00
co-authored by Claude Opus 4.8
parent 7ffd75e8ec
commit 7775a4ed6d
+10
View File
@@ -1,6 +1,7 @@
<?php
namespace Grav\Plugin;
use Grav\Common\Cache;
use Grav\Common\Data\ValidationException;
use Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;
@@ -190,7 +191,16 @@ class CacheOnSavePlugin extends Plugin
}
}
// Two-part invalidation. deleteAll() drops the Doctrine store (the tracker
// feed page cache etc.), but the page-tree INDEX is keyed on
// md5(dirs + folderHash + config->checksum() + lang) (Pages::buildRegularPages).
// With cache.check.method:folder that index can survive a create — a fresh
// entry then stays invisible to the API (GET /api/v1/pages{route} 404s), so
// opening the just-posted entry for editing shows "this entry no longer
// exists". invalidateCache() touches system.yaml, bumping config->checksum()
// so the index key changes and the tree rebuilds on the next request.
$this->grav['cache']->deleteAll();
Cache::invalidateCache();
}
/**