Fix build against PHP 8.6 (php_verror params argument removed) - #629
Fix build against PHP 8.6 (php_verror params argument removed)#629andypost wants to merge 1 commit into
Conversation
php-src commit 0a12b3e8268 (php/php-src#22865) removed the docref params argument from php_verror(), changing its signature from 5 to 4 arguments. Since a PHP_VERSION_ID guard cannot distinguish 8.6-dev snapshots taken before and after that change, format the message with vspprintf() and report it through php_error_docref(), whose signature is stable across all supported versions. Passing NULL docref and empty params to php_verror() was equivalent to php_error_docref(NULL, ...) anyway. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JNDQDyaiHPPMtsno9Kyo4t
f2566fd to
eac054a
Compare
|
Faced it at Drupal's nightly pipeline https://git.drupalcode.org/project/drupalci_environments/-/jobs/11143560 |
| /* console display functions */ | ||
| #define APC_PRINT_FUNCTION(name, verbosity) \ | ||
| void apc_##name(const char *format, ...) \ | ||
| { \ | ||
| va_list args; \ | ||
| char *buf; \ | ||
| \ | ||
| va_start(args, format); \ | ||
| php_verror(NULL, "", verbosity, format, args); \ | ||
| vspprintf(&buf, 0, format, args); \ | ||
| va_end(args); \ | ||
| php_error_docref(NULL, verbosity, "%s", buf); \ | ||
| efree(buf); \ | ||
| } | ||
|
|
||
| APC_PRINT_FUNCTION(error, E_ERROR) | ||
| APC_PRINT_FUNCTION(warning, E_WARNING) | ||
| APC_PRINT_FUNCTION(notice, E_NOTICE) | ||
|
|
||
| #ifdef APC_DEBUG | ||
| APC_PRINT_FUNCTION(debug, E_NOTICE) | ||
| #else | ||
| void apc_debug(const char *format, ...) {} | ||
| #endif |
There was a problem hiding this comment.
Generating functions with a macro-mechanism seems unnecessarily complex here. Especially since all the generated functions do pretty much exactly what php_error_docref() does. I know it was like that before, but I think it's time to change it, now.
It's probably better to remove these functions / macros completely from apc.c and replace the definitions in apc.h with macros that propagate the variadic data directly to php_error_docref().
Therefore, i propose to replace this...
Lines 80 to 84 in bc9e296
by something like this:
/* convenience macros for console output */
#define apc_error(...) php_error_docref(NULL, E_ERROR, __VA_ARGS__)
#define apc_warning(...) php_error_docref(NULL, E_WARNING, __VA_ARGS__)
#define apc_notice(...) php_error_docref(NULL, E_NOTICE, __VA_ARGS__)
#ifdef APC_DEBUG
# define apc_debug(...) php_error_docref(NULL, E_NOTICE, __VA_ARGS__)
#else
# define apc_debug(...) do {} while (0)
#endif
There was a problem hiding this comment.
Sounds like great idea and clean-up but it breaks ABI so not clear if it allowed
|
Opened #630 as an alternative that implements @madmajestro's review suggestion: replace the generated console functions with macros forwarding to |
|
After a closer look I recommend closing this PR in favor of #630. Reviewing my own diff here turned up a structural defect: for The defect can't be patched within this PR's shape: the buffer can't be freed before the call (it is the argument) nor after (bailout jumped away). The only fix is to not allocate — i.e. forward format+args directly to Both PRs are green across the full CI matrix including the 8.6 job. Leaving this open only as the minimal fallback if the |
|
I am closing this as it has been superseded by #630, which was recently merged. |
php-src commit 0a12b3e8268 (php/php-src#22865, merged 2026-07-24) removed the docref
paramsargument fromphp_verror(), changing its signature from 5 to 4 arguments. Since then APCu fails to compile against master:This adds a version-guarded
apc_php_verror()wrapper macro (a#ifcannot live inside theAPC_PRINT_FUNCTIONmacro body), so the code builds against both PHP 8.6-dev and older versions.🤖 Generated with Claude Code
https://claude.ai/code/session_01JNDQDyaiHPPMtsno9Kyo4t