| 1 | Patch-Source: https://github.com/krakjoe/apcu/commit/d29e907791502af89a7996930f8dce5fd8efe4a1
|
| 2 | From d29e907791502af89a7996930f8dce5fd8efe4a1 Mon Sep 17 00:00:00 2001
|
| 3 | From: Andy Postnikov <[email protected]>
|
| 4 | Date: Fri, 10 Apr 2026 02:28:52 +0200
|
| 5 | Subject: [PATCH] Fix build against PHP 8.6 (EMPTY_SWITCH_DEFAULT_CASE removed)
|
| 6 |
|
| 7 | Replace EMPTY_SWITCH_DEFAULT_CASE() with ZEND_UNREACHABLE() in
|
| 8 | apc_persist.c and add a fallback definition for PHP < 8.0 in apc.h,
|
| 9 | matching php-src debug/release behavior.
|
| 10 | ---
|
| 11 | apc.h | 10 ++++++++++
|
| 12 | apc_persist.c | 6 ++++--
|
| 13 | 2 files changed, 14 insertions(+), 2 deletions(-)
|
| 14 |
|
| 15 | diff --git a/apc.h b/apc.h
|
| 16 | index 6e725d04..8bbe3971 100644
|
| 17 | |
| 18 | |
| 19 | @@ -67,6 +67,16 @@
|
| 20 | #include "php.h"
|
| 21 | #include "main/php_streams.h"
|
| 22 |
|
| 23 | +/* ZEND_UNREACHABLE() was added in PHP 8.0. Provide fallback for PHP 7.x.
|
| 24 | + * Remove this block when APCu drops support for PHP < 8.0. */
|
| 25 | +#if PHP_VERSION_ID < 80000
|
| 26 | +# if ZEND_DEBUG
|
| 27 | +# define ZEND_UNREACHABLE() do {ZEND_ASSERT(0); ZEND_ASSUME(0);} while (0)
|
| 28 | +# else
|
| 29 | +# define ZEND_UNREACHABLE() ZEND_ASSUME(0)
|
| 30 | +# endif
|
| 31 | +#endif
|
| 32 | +
|
| 33 | /* console display functions */
|
| 34 | PHP_APCU_API void apc_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
|
| 35 | PHP_APCU_API void apc_warning(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
|
| 36 | diff --git a/apc_persist.c b/apc_persist.c
|
| 37 | index e322b8d2..531695f3 100644
|
| 38 | |
| 39 | |
| 40 | @@ -244,7 +244,8 @@ static zend_bool apc_persist_calc_zval(apc_persist_context_t *ctxt, const zval *
|
| 41 | case IS_RESOURCE:
|
| 42 | apc_warning("Cannot store resources in apcu cache");
|
| 43 | return 0;
|
| 44 | - EMPTY_SWITCH_DEFAULT_CASE()
|
| 45 | + default:
|
| 46 | + ZEND_UNREACHABLE();
|
| 47 | }
|
| 48 | }
|
| 49 |
|
| 50 | @@ -450,7 +451,8 @@ static void apc_persist_copy_zval_impl(apc_persist_context_t *ctxt, zval *zv) {
|
| 51 | if (!ptr) ptr = apc_persist_copy_ref(ctxt, Z_REF_P(zv));
|
| 52 | ZVAL_REF(zv, ptr);
|
| 53 | return;
|
| 54 | - EMPTY_SWITCH_DEFAULT_CASE()
|
| 55 | + default:
|
| 56 | + ZEND_UNREACHABLE();
|
| 57 | }
|
| 58 | }
|