Skip to content

MD-2145: Fix Snap advanced feeds stale deadline cache - #13

Open
dvdcastro wants to merge 2 commits into
developfrom
MD-2145
Open

MD-2145: Fix Snap advanced feeds stale deadline cache#13
dvdcastro wants to merge 2 commits into
developfrom
MD-2145

Conversation

@dvdcastro

@dvdcastro dvdcastro commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two-part fix for the Snap advanced feeds cache invalidation bug (MD-2145).

Commit 1 — Backend cache purge on date changes

  • report/editdates/index.php: Purges the theme_snap/activity_deadlines MUC cache whenever report_editdates saves updated dates, so the server-side cache rebuilds immediately after dates change.

Commit 2 — Frontend localStorage invalidation (ports open-lms-open-source/moodle-theme_snap#312)

  • theme/snap/classes/local.php: Reads the MUC cache timestamp and injects it as cacheVersion into each feed item returned by the deadlines API.
  • theme/snap/classes/webservice/ws_feed.php: Declares cacheVersion as optional in the web service return structure.
  • theme/snap/vendorjs/.../feed.service.ts: FeedService compares cacheVersion against the stored value; on mismatch, invalidates localStorage and re-fetches.
  • theme/snap/vendorjs/.../feed-item.ts + cached-moodle-res.ts: Type definitions updated.

Note: snap-ce.js (compiled bundle) not updated — needs rebuild from TypeScript sources. Sources are correctly patched.

Test plan

  • Update a deadline via report_editdates
  • Without clearing browser cache, reload Snap dashboard → deadlines should reflect the new date immediately
  • Verify existing deadline display is unaffected when no date changes occur

Fixes MD-2145 | References: open-lms-open-source/moodle-theme_snap#312

…aves dates

When report_editdates saves activity dates, mod->save_dates() does not
reliably fire \core\event\calendar_event_updated for all module types
(e.g. forums), so theme_snap event_handlers::calendar_change never
invalidates the activity_deadlines MUC cache.

This patch explicitly purges the activity_deadlines cache after the
transaction commits and course cache rebuilds, so the next request
serves fresh deadline data to the frontend instead of stale cached data.

The frontend 30-min localStorage TTL is intentionally preserved (the
original caching was added to avoid expensive calendar queries, which
are now served from the backend MUC cache).

Fixes MD-2145.
@dvdcastro
dvdcastro force-pushed the MD-2145 branch 2 times, most recently from 68584ac to a2da0ec Compare April 2, 2026 10:48
…r deadlines

Ports open-lms-open-source/moodle-theme_snap#312.

Adds a cacheVersion field (server-side MUC cache timestamp) to each feed
item returned by the deadlines web service. The frontend FeedService uses
this to detect when server data has changed and invalidates the localStorage
cache, so students see correct deadlines immediately after dates are updated
via report_editdates or any other backend change.

snap-ce.js (compiled bundle) excluded — needs a rebuild from the TypeScript
sources which are patched here.
@dvdcastro dvdcastro changed the title MD-2145: Purge snap activity_deadlines cache after report_editdates saves dates MD-2145: Fix Snap advanced feeds stale deadline cache Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant