feat(19.3-04): purge the host site's page cache after menu and menu-entry saves, deletes and reorders

- menus controller gains the app accessor and FormAfterCreate/Update/Delete
  purging kind menu with the menu code
- menu entries purge kind menu_entry with the entry id after the placement
  checks pass, on delete, and through pact.ReorderAfterSave with
  partition:<menu id>
- purgeSiteCache helper on cabana.TxFromContext and cooler.SiteCacheFromApp
- TestMenuAdminPurgesSiteCache on Postgres
This commit is contained in:
Jakub Zych
2026-10-15 18:30:45 +02:00
parent 9c0f833878
commit 559d96b0a4
6 changed files with 414 additions and 10 deletions

32
controllers/site_cache.go Normal file
View File

@@ -0,0 +1,32 @@
package controllers
import (
"context"
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/cabana"
"git.golem15.com/golem15/summercms/modules/cooler"
)
// purgeSiteCache registers one site-cache purge of kind and slug, sent by
// the framework's purger (site_cache.purge_url and purge_token) after the
// save transaction of ctx commits. Without a purge configured, or outside a
// save transaction, it does nothing. A purge never fails the save.
func purgeSiteCache(ctx context.Context, app func() *backpack.App, kind, slug string) {
if app == nil {
return
}
a := app()
if a == nil {
return
}
tx, ok := cabana.TxFromContext(ctx)
if !ok {
return
}
purger := cooler.SiteCacheFromApp(a)
if purger == nil {
return
}
cooler.PurgeSiteCacheAfterCommit(ctx, tx, purger, kind, slug)
}