| 1 | Patch-Source: https://github.com/krakjoe/apcu/commit/90899684be91c4f750512c2f840f487286ecb807
|
| 2 | From 90899684be91c4f750512c2f840f487286ecb807 Mon Sep 17 00:00:00 2001
|
| 3 | From: Andy Postnikov <[email protected]>
|
| 4 | Date: Sat, 25 Jul 2026 20:10:30 +0200
|
| 5 | Subject: [PATCH] Simplify console output helpers to macros over
|
| 6 | php_error_docref
|
| 7 |
|
| 8 | Replace the APC_PRINT_FUNCTION macro that generated four exported
|
| 9 | apc_error/apc_warning/apc_notice/apc_debug functions with thin variadic
|
| 10 | macros in apc.h that forward directly to php_error_docref(), and drop the
|
| 11 | generator block from apc.c entirely.
|
| 12 |
|
| 13 | This also fixes the build against PHP 8.6-dev: php/php-src@0a12b3e8268
|
| 14 | removed the params argument from php_verror(), which the old
|
| 15 | APC_PRINT_FUNCTION body called. Forwarding to php_error_docref() instead
|
| 16 | sidesteps php_verror() altogether and works on all supported versions.
|
| 17 |
|
| 18 | Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
| 19 | ---
|
| 20 | apc.c | 21 ---------------------
|
| 21 | apc.h | 14 ++++++++++----
|
| 22 | 2 files changed, 10 insertions(+), 25 deletions(-)
|
| 23 |
|
| 24 | diff --git a/apc.c b/apc.c
|
| 25 | index e2d039ca..c6f4f16f 100644
|
| 26 | |
| 27 | |
| 28 | @@ -34,27 +34,6 @@
|
| 29 | #include "apc_globals.h"
|
| 30 | #include "php.h"
|
| 31 |
|
| 32 | -/* console display functions */
|
| 33 | -#define APC_PRINT_FUNCTION(name, verbosity) \
|
| 34 | - void apc_##name(const char *format, ...) \
|
| 35 | - { \
|
| 36 | - va_list args; \
|
| 37 | - \
|
| 38 | - va_start(args, format); \
|
| 39 | - php_verror(NULL, "", verbosity, format, args); \
|
| 40 | - va_end(args); \
|
| 41 | - }
|
| 42 | -
|
| 43 | -APC_PRINT_FUNCTION(error, E_ERROR)
|
| 44 | -APC_PRINT_FUNCTION(warning, E_WARNING)
|
| 45 | -APC_PRINT_FUNCTION(notice, E_NOTICE)
|
| 46 | -
|
| 47 | -#ifdef APC_DEBUG
|
| 48 | -APC_PRINT_FUNCTION(debug, E_NOTICE)
|
| 49 | -#else
|
| 50 | -void apc_debug(const char *format, ...) {}
|
| 51 | -#endif
|
| 52 | -
|
| 53 | HashTable* apc_flip_hash(HashTable *hash) {
|
| 54 | zval data, *entry;
|
| 55 | HashTable *new_hash;
|
| 56 | diff --git a/apc.h b/apc.h
|
| 57 | index 8bbe3971..cd9fa585 100644
|
| 58 | |
| 59 | |
| 60 | @@ -78,10 +78,16 @@
|
| 61 | #endif
|
| 62 |
|
| 63 | /* console display functions */
|
| 64 | -PHP_APCU_API void apc_error(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
|
| 65 | -PHP_APCU_API void apc_warning(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
|
| 66 | -PHP_APCU_API void apc_notice(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
|
| 67 | -PHP_APCU_API void apc_debug(const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2);
|
| 68 | +#define apc_error(...) php_error_docref(NULL, E_ERROR, __VA_ARGS__)
|
| 69 | +#define apc_warning(...) php_error_docref(NULL, E_WARNING, __VA_ARGS__)
|
| 70 | +#define apc_notice(...) php_error_docref(NULL, E_NOTICE, __VA_ARGS__)
|
| 71 | +
|
| 72 | +#ifdef APC_DEBUG
|
| 73 | +# define apc_debug(...) php_error_docref(NULL, E_NOTICE, __VA_ARGS__)
|
| 74 | +#else
|
| 75 | +/* if (0) keeps compile-time format checking at zero runtime cost */
|
| 76 | +# define apc_debug(...) do { if (0) php_error_docref(NULL, E_NOTICE, __VA_ARGS__); } while (0)
|
| 77 | +#endif
|
| 78 |
|
| 79 | /* apc_flip_hash flips keys and values for faster searching */
|
| 80 | PHP_APCU_API HashTable* apc_flip_hash(HashTable *hash);
|