Skip to content

fix: single album page cache entry, working 304s, hero template in dark theme - #137

Merged
fabiodalez-dev merged 4 commits into
mainfrom
fix/hero-dark-and-album-warm
Oct 13, 2026
Merged

fabiodalez-dev merged 4 commits into
mainfrom
fix/hero-dark-and-album-warm

Conversation

@fabiodalez-dev

@fabiodalez-dev fabiodalez-dev commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #132 and #136: two loose ends I noted while reviewing, plus what turned up while fixing them.

1. One cache entry per album page

The album page was rendered from the album_<id> entry, while every warm wrote a second, partially built album:<slug> entry. That second entry was never rendered, but CacheMiddleware took the page ETag from it, so the validator did not follow the page: a settings change that altered the album layout left the ETag unchanged.

  • PageCacheService::albumPageKey() is now the single key format, used by PageController (render), CacheMiddleware (ETag) and invalidateAlbum(). A ?template=N request falls back to hashing the body.
  • The partial album warm is removed. Home and galleries are still pre-built; album pages are cached on their first anonymous visit and rebuilt single-flight after an edit (fix(cache): album, category and tag pages stayed stale after an edit #136). This follows what buildGalleriesCache() already does when it cannot reproduce the live page faithfully.
  • cache:warm keeps accepting --albums and says album pages need no pre-build; the admin Cache page clears album entries instead of reporting a regeneration that never fed the page.
  • File backend: stats and "clear all" now cover every page entry (album, category, tag), not just home and galleries.

2. 304 never happened behind a compressing Apache

Apache appends -gzip / -br to the ETag when it compresses the response, and the browser sends that back in If-None-Match. The comparison did not strip the suffix, so a compressed page could never revalidate to 304. normalizeEtag() now ignores the content-coding suffix.

3. Hero album template in the dark theme

The readability veil over the hero image was a fixed white gradient and the panel forced dark text, while the pills inside switched to their dark styles: dark pills with dark text on a white panel, and body text that turned light on white. The veil now uses the theme surface colour (--color-bg-secondary-rgb), so the panel follows the theme and everything inside uses its normal styles. The .preserve-light-text override, only used here, is removed. Light theme rendering is unchanged.

4. Test coverage

  • album-edit-cache.spec.js ECA-03: 304 on an unchanged album page, 200 with a new ETag after a layout change.
  • HeroPanelThemeTest: the hero veil must use the theme surface colour.
  • AdminSidebarTranslationsTest now also covers the two bundled plugins (CodeRabbit's note on Translate admin sidebar subtitles in English and Italian #128).

Verification

  • PHPUnit: 213 tests OK. PHPStan: no errors on app/ (two baseline entries for the removed PageCacheService::warm() dropped).
  • Semgrep (--config auto, baseline v1.4.23): no new findings.
  • Full e2e suite run sequentially against Apache on localhost: the specs that failed in that run pass when re-run, except the Home template: classic screenshot spec, which fails the same way on v1.4.23 when it runs right after album-state-transitions: the analytics beacon hits its 60/min per-IP limit, the 429 keeps the page from reaching network idle. Not caused by this PR.
  • Checked the hero template in light and dark, desktop and mobile, and the admin Cache page (list, clear albums, warm all).

Summary by CodeRabbit

  • Modifiche
    • Il preriscaldamento genera cache per la home e la pagina gallerie; le pagine degli album vengono memorizzate alla prima visita anonima e rigenerate dopo un’invalidazione. Gli album NSFW e protetti da password restano esclusi.
    • Aggiornata la gestione delle cache degli album e delle varianti di template.
    • Migliorato l’aspetto dell’hero e delle etichette in base al tema, incluso quello scuro.
  • Documentazione
    • Aggiornate le indicazioni sul preriscaldamento delle cache e sull’opzione --albums.
  • Test
    • Aggiunti controlli per la visualizzazione dell’hero e per gli ETag al cambio di template.

…and invalidation

The album page was rendered from the album_<id> entry while a second, partially built album:<slug> entry was written by every warm. That second entry was never rendered, but CacheMiddleware took the page ETag from it, so the validator did not follow the page: a settings change that altered the album layout left the ETag unchanged.

PageCacheService::albumPageKey() is now the single key format. The ETag is read from that entry (a ?template=N request falls back to hashing the body), invalidateAlbum() targets it, and the partial album warm is removed: home and galleries are still pre-built, album pages are cached on their first anonymous visit and rebuilt single-flight after an edit. cache:warm keeps accepting --albums and says so; the admin Cache page clears album entries instead of pretending to regenerate them. The file backend now lists and clears every page entry, not just home and galleries.

ETag comparison also ignores the -gzip / -br suffix Apache appends when it compresses the response; with it, a compressed page could never revalidate to 304.

e2e: ECA-03 in album-edit-cache.spec.js covers the 304 on an unchanged page and the 200 after a layout change.
The readability veil over the hero image was a fixed white gradient and the panel forced dark text, while the category, tag and date pills inside it switched to their dark styles: dark pills with dark text on a white panel, and album body text that turned light on white.

The veil now uses the theme surface colour (--color-bg-secondary-rgb), so the panel is white in the light theme and near-black in the dark one and everything inside uses its normal light/dark styles. The .preserve-light-text override, only used here, is removed. Light theme rendering is unchanged.
The test only read the admin layout, so a plugin subtitle going back to a fixed string, or a language pack missing a plugin key, would have gone unnoticed (the trans() default hides a missing key).
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3d2db4e-7fa4-4537-824e-6a051ea62f8a
📥 Commits

Reviewing files that changed from the base of the PR and between 5999025 and 7363fb5.

📒 Files selected for processing (19)
  • .gitignore
  • README.md
  • app/Controllers/Admin/AlbumsController.php
  • app/Controllers/Admin/AuthController.php
  • app/Controllers/Admin/CacheController.php
  • app/Controllers/Frontend/PageController.php
  • app/Middlewares/CacheMiddleware.php
  • app/Services/CacheWarmService.php
  • app/Services/PageCacheService.php
  • app/Tasks/CacheWarmCommand.php
  • app/Views/frontend/gallery_hero.twig
  • phpstan-baseline.neon
  • public/assets/.vite/manifest.json
  • public/assets/app-CXV8McJM.css
  • public/assets/app.css
  • resources/app.css
  • tests/Views/AdminSidebarTranslationsTest.php
  • tests/Views/HeroPanelThemeTest.php
  • tests/e2e/album-edit-cache.spec.js
💤 Files with no reviewable changes (3)
  • app/Controllers/Admin/AuthController.php
  • resources/app.css
  • phpstan-baseline.neon

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Le cache album passano a chiavi basate sull’ID e non vengono più preriscaldate. Le richieste anonime generano le pagine album e gli ETag considerano i parametri query. Il pannello hero adatta i propri stili al tema. I test delle traduzioni includono anche i plugin.

Changes

Cache delle pagine

Layer / File(s) Summary
Chiavi e gestione dei file cache
app/Services/PageCacheService.php
Il servizio genera chiavi album basate sull’ID, risolve gli slug e aggiorna invalidazione, percorsi e statistiche dei file cache.
Invalidazione e riscaldamento
app/Controllers/Admin/AlbumsController.php, app/Controllers/Admin/AuthController.php, app/Controllers/Admin/CacheController.php, app/Services/CacheWarmService.php, app/Tasks/CacheWarmCommand.php, README.md, phpstan-baseline.neon
Le modifiche agli album invalidano le cache senza pianificarne il riscaldamento. Il preriscaldamento e i relativi conteggi riguardano home e gallerie. L’opzione --albums resta accettata per compatibilità.
Cache album ed ETag
app/Controllers/Frontend/PageController.php, app/Middlewares/CacheMiddleware.php, tests/e2e/album-edit-cache.spec.js
La pagina usa le chiavi centralizzate. Gli ETag considerano i parametri query, escludono le richieste con template e rimuovono i suffissi di codifica. Il test verifica la risposta condizionale dopo un cambio di template.

Tema del pannello hero

Layer / File(s) Summary
Stili del pannello hero
app/Views/frontend/gallery_hero.twig, resources/app.css, public/assets/.vite/manifest.json, tests/Views/HeroPanelThemeTest.php, .gitignore
Il template usa colori del tema per il velo e le etichette. Il CSS rimuove le regole preserve-light-text; il test verifica l’uso della variabile RGB e l’assenza degli stili precedenti.

Traduzioni della sidebar

Layer / File(s) Summary
Controlli sui plugin
tests/Views/AdminSidebarTranslationsTest.php
Il test controlla i sottotitoli Smarty e le chiavi di traduzione della sidebar nei plugin inclusi.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ClientAnonimo
  participant CacheMiddleware
  participant PageCacheService
  participant PageController
  ClientAnonimo->>CacheMiddleware: Richiede la pagina album con i parametri query
  CacheMiddleware->>PageCacheService: Risolve la chiave album dallo slug
  PageCacheService-->>CacheMiddleware: Restituisce la chiave o null
  CacheMiddleware->>PageController: Prosegue la richiesta
  PageController->>PageCacheService: Legge o salva la pagina con albumPageKey
  PageCacheService-->>PageController: Restituisce o registra la pagina
  CacheMiddleware-->>ClientAnonimo: Restituisce la risposta con l'ETag
Loading

Suggested reviewers: miranoverhoef

Merge Risk: ⚪ Minimal · up to 7363f

The change moves album page caching to ID-based keys, adjusts ETag handling, and updates hero panel dark-theme styling. No actionable merge-blocking issue was found.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 10 files. (4 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed Il titolo descrive in modo chiaro i principali cambiamenti: cache delle pagine album, risposte 304 tramite ETag e tema scuro per il template hero.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 10 files. (4 skipped: 4 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 PHPStan (2.2.14)

PHPStan was skipped because the config uses disallowed bootstrapFiles or bootstrapFile directives.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Un coniglio saltella tra chiavi e cache,
la home si scalda, l’album attende.
Un tema scuro veste l’hero,
nuove chiavi brillano nei test.
«Tutto in ordine», squittisce allegro,
e lascia impronte sulla neve.

Comment @coderabbitai help to get the list of available commands.

@fabiodalez-dev
fabiodalez-dev merged commit f9a6cba into main Oct 13, 2026
2 checks passed
@fabiodalez-dev
fabiodalez-dev deleted the fix/hero-dark-and-album-warm branch October 13, 2026 08:34
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