Patch-Source: https://github.com/krakjoe/apcu/commit/d29e907791502af89a7996930f8dce5fd8efe4a1 From d29e907791502af89a7996930f8dce5fd8efe4a1 Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Fri, 10 Apr 2026 02:28:52 +0200 Subject: [PATCH] Fix build against PHP 8.6 (EMPTY_SWITCH_DEFAULT_CASE removed) Replace EMPTY_SWITCH_DEFAULT_CASE() with ZEND_UNREACHABLE() in apc_persist.c and add a fallback definition for PHP < 8.0 in apc.h, matching php-src debug/release behavior. --- apc.h | 10 ++++++++++ apc_persist.c | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apc.h b/apc.h index 6e725d04..8bbe3971 100644 --- a/apc.h +++ b/apc.h @@ -67,6 +67,16 @@ #include "php.h" #include "main/php_streams.h" +/* ZEND_UNREACHABLE() was added in PHP 8.0. Provide fallback for PHP 7.x. + * Remove this block when APCu drops support for PHP < 8.0. */ +#if PHP_VERSION_ID < 80000 +# if ZEND_DEBUG +# define ZEND_UNREACHABLE() do {ZEND_ASSERT(0); ZEND_ASSUME(0);} while (0) +# else +# define ZEND_UNREACHABLE() ZEND_ASSUME(0) +# endif +#endif + /* console display functions */ PHP_APCU_API void apc_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2); PHP_APCU_API void apc_warning(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2); diff --git a/apc_persist.c b/apc_persist.c index e322b8d2..531695f3 100644 --- a/apc_persist.c +++ b/apc_persist.c @@ -244,7 +244,8 @@ static zend_bool apc_persist_calc_zval(apc_persist_context_t *ctxt, const zval * case IS_RESOURCE: apc_warning("Cannot store resources in apcu cache"); return 0; - EMPTY_SWITCH_DEFAULT_CASE() + default: + ZEND_UNREACHABLE(); } } @@ -450,7 +451,8 @@ static void apc_persist_copy_zval_impl(apc_persist_context_t *ctxt, zval *zv) { if (!ptr) ptr = apc_persist_copy_ref(ctxt, Z_REF_P(zv)); ZVAL_REF(zv, ptr); return; - EMPTY_SWITCH_DEFAULT_CASE() + default: + ZEND_UNREACHABLE(); } }