Repository navigation
feat: Store an expiry per presence row - #541
Conversation
🚩 New public surface
|
🛝 WordPress PlaygroundsBuilt from 11dc205
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #541 +/- ##
============================================
- Coverage 96.02% 95.95% -0.08%
Complexity 258 258
============================================
Files 21 21
Lines 3123 3141 +18
============================================
+ Hits 2999 3014 +15
- Misses 124 127 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
…n window wp_set_presence takes expires_in, reads and cleanup use expires_gmt, and a connection-backed writer stops re-stamping.
…ute a cutoff The readers still accept timeout for their callers, so the docblocks say it no longer narrows a result.
The expiry cap defaults to it, and PHPStan cannot see WordPress constants the bootstrap does not list.
…an hour A row may now outlive the TTL, so the privacy text and export print the longest window any row can carry.
…he README Consumers read the signature there, and the timeout parameter no longer narrows a read.
…s given The branch ran on every write but no test naming the helper credited it, so coverage reported a miss.
…se it Coverage is attributed through covers annotations, so the helper read as uncovered despite two tests driving it.
b85f060 to
2f17c5b
Compare
josephfusco
left a comment
There was a problem hiding this comment.
LGTM, nice first contribution!
|
@josephfusco Thanks for carrying the rebase and the
Hopefully first of many 😄 |
Closes #539.
Each row now carries its own expiry, so a writer that knows when its clients leave can write once and remove the row itself, instead of re-stamping it inside the TTL.
Before
sequenceDiagram participant W as Writer participant DB as wp_presence participant R as Reader W->>DB: set_presence() stamps date_gmt loop every ~120s, or the row vanishes W->>DB: re-stamp date_gmt end R->>DB: live if date_gmt > now - TTLAfter
sequenceDiagram participant W as Writer participant DB as wp_presence participant R as Reader W->>DB: set_presence( ..., expires_in ) once R->>DB: live if expires_gmt > now W->>DB: remove_presence() when the client leaves Note over DB: cron deletes expires_gmt <= nowShape
expires_gmtis always set, so every liveness check is one indexed predicate.$date_gmt, so a backdated row expires on the writer's clock.wp_presence_max_expires_incaps the window, default one hour. The privacy policy text and the personal data export report that cap, since it is the most any row can outlive its last activity.wp_presence_default_ttlapplies at write time. Changing it does not re-age stored rows; anyone still present picks up the new value on their next ping.Most likely to be wrong
$timeouton the readers is a no-op. Honouring it meansexpires_gmt > %s AND date_gmt > %s, the predicate this removes. The parameters stay because dropping a positional argument turnswp_get_presence( $room, 30 )into a prefix lookup that silently returns nothing._deprecated_argument()on a non-default value is the natural next step; A site's wp_presence_default_ttl filter overrides a consumer's own timeout window #515 is the case for keeping the narrowing.wp presence cleanupdoes it at once.expires_gmt <= %s; it readdate_gmt < %swhile reads used>, leaving a row on the cutoff neither live nor deletable.Tested
Single-site (518 tests, 143 skipped) and multisite (518, 3 skipped)
Use of AI Tools
Claude Code (Fable 5)