From 2d21d0f91a79995fda855f09bfdc96d5265085d9 Mon Sep 17 00:00:00 2001 From: Luther Monson Date: Mon, 22 Jun 2026 07:42:15 -0700 Subject: [PATCH] fix: guard flush() so it degrades gracefully on pre-v0.1.2 ePHPm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SapiKvOps::flush() called ephpm_kv_flush_all() unconditionally. That SAPI function only exists in ePHPm v0.1.2+, so on an older runtime wp_cache_flush() would fatal with 'Call to undefined function' rather than no-op. Guard with function_exists (matching ephpm/predis-connection): flush returns false on older runtimes and entries age out via TTL. Decouples the drop-in from the ePHPm release — it can ship now and flush lights up automatically once v0.1.2 is deployed. --- src/SapiKvOps.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/SapiKvOps.php b/src/SapiKvOps.php index 085c154..023d295 100644 --- a/src/SapiKvOps.php +++ b/src/SapiKvOps.php @@ -66,6 +66,14 @@ public function pttl(string $key): int public function flush(): bool { + // ephpm_kv_flush_all() was added after the original SAPI surface + // (ePHPm v0.1.2). Guard it so the drop-in still works on older + // runtimes: flush is simply unavailable there (wp_cache_flush() + // returns false and entries age out via TTL) rather than fataling + // the request with "Call to undefined function". + if (!\function_exists('ephpm_kv_flush_all')) { + return false; + } return (bool) \ephpm_kv_flush_all(); } }