Skip to content

Audit fixes (2026-09) - #3

Merged
luthermonson merged 1 commit into
mainfrom
fix/audit-2026-09
Sep 11, 2026
Merged

luthermonson merged 1 commit into
mainfrom
fix/audit-2026-09

Conversation

@luthermonson

Copy link
Copy Markdown
Contributor

Audited KV/cache fixes for cache-wordpress. Adopts ephpm_kv_setnx where it was missing (atomic add()/NX/locks), stops reporting OOM writes as success, fixes the incrBy false->0 cast across the copied KvOps, and refreshes docs/CI. Every behavioral change has a test (agent ran the suite green in WSL PHP 8.5).

…ntics

- add(): make the persistent path atomic via ephpm_kv_setnx instead of the
  racy exists()-then-set(). WordPress uses wp_cache_add() as a cron/lock
  mutex, so two concurrent add()s must not both win. The runtime-only
  (non-persistent) path keeps its check-then-set behavior.
- KvOpsInterface/SapiKvOps/InMemoryKvOps: add setnx() (the atomic add
  primitive; true=inserted, false=already present or OOM).
- SapiKvOps::incrBy(): stop masking a non-integer stored value. The SAPI
  returns false in that case and (int) false === 0 silently swallowed it;
  now it throws RuntimeException as the interface documents.
- wp_cache_supports('flush_group') now returns false. The persistent tier
  cannot be selectively flushed (no key-scan primitive), so advertising it
  over-promised. Batch caps and flush_runtime stay advertised.
- incr()/decr(): align with WP core — a missing key returns false rather
  than being created at the delta (the raw KV incr_by would create it).
  Applies to both the persistent (existsInStore gate) and runtime paths.
- get() with force=true on a non-persistent group now stays local instead
  of spuriously missing through to the (absent) persistent store.
- README: current release v0.10.2 (v0.1.2 floor preserved); document the
  atomic add, flush_group=false, and incr miss semantics; list ephpm_kv_setnx.
- Tests: atomic add() race (two caches over one backend), add() uses setnx,
  incr miss -> false (persistent + non-persistent), force-read of a
  non-persistent group stays local, setnx (InMemory + SAPI stub), and the
  incrBy non-integer throw. wp_cache_supports('flush_group') === false.
@luthermonson
luthermonson merged commit 19226c2 into main Sep 11, 2026
3 checks passed
@luthermonson
luthermonson deleted the fix/audit-2026-09 branch September 11, 2026 06:47
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