Skip to content

Trending Now 1.1.6

Choose a tag to compare

@ivanmorales ivanmorales released this 08 Aug 16:45
· 60 commits to main since this release

Fixes archive pagination introduced in 1.1.5. Recommended for anyone running 1.1.5.

Fixed

  • The archive paginated over a set it was no longer showing. 1.1.5 made max_age_hours bound /trending/, but the archive's item count is cached in a transient for 15 minutes and nothing invalidated it when the set it counts changed. A site with 2,500 retained rows and 350 inside the window offered 50 pages of which 7 had anything on them, and the pages past the seventh returned 200 with an empty list — prepare_response() could not redirect them, because it decides what is out of range by reading the same stale number.

    ADVTN_Ingest::finalize() now drops the count. It already marks rows stale, prunes them and purges both the render cache and the host page cache; the count is derived from the same rows and had simply been left out.

    That omission outlived its own 15-minute TTL, which is why the wrong pagination persisted rather than ageing out: the page cache purge re-primes the archive HTML on the next request and bakes whatever count is current into pages that then live for the page cache's own lifetime.

    Two further guards, because a 15-minute cache over a window that moves every second will always be slightly wrong at the edges:

    • A page past the first that resolves to no rows now redirects to page 1 instead of serving an empty page 200. Empty indexable pages are worse than a redirect.
    • The upgrade to database version 3 clears any count cached by an earlier version, so existing sites are corrected on upgrade rather than leaving it for the first visitor to trip over.

    ADVTN_Archive::current_items() is memoized so the new emptiness check costs no extra query — an archive pageview still issues exactly one, verified under SAVEQUERIES.

Reproduced at production scale before the fix (2,546 rows, 77 inside the window): Page 1 of 51, with /trending/page/40/ returning 200 and zero items. After: that page redirects, finalize() clears the count, and the upgrade path clears it too.