[php-src] PR #25352: Fix truncated anonymous class names in error messages and logs
| From: | jorgsowa | Date: | Mon, 09 Nov 2026 20:55:36 +0000 |
| Subject: | [php-src] PR #25352: Fix truncated anonymous class names in error messages and logs | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40480@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25352
Author: jorgsowa
I detected this problem while working on PHP Parser in Rust.
Anonymous class names contain a NUL byte (
class@anonymous\0file:line$0). Since the
%pS migration (#23142), some error messages include the full name, which exposed two
problems:
1. Messages cut off in output. php_error_cb() still wrote the message as a C string in
the error log, the HTML fatal error output and the XML-RPC fault, so it stopped at the NUL:
PHP Fatal error: Class class@anonymous in Standard input code on line 2
The log now writes NUL bytes as \0 (log sinks take C strings), and the HTML/XML-RPC
output prints the message by length.
2. Inconsistent names. Messages not covered by the migration still printed the short name via
ZSTR_VAL() / ZEND_FN_SCOPE_NAME(), sometimes both forms in one message:
Class class@anonymous\0…:2$0 must implement 1 abstract method (class@anonymous::$p::get)
These now use %pS: inheritance errors (abstract method list, #[\Override],
access level, static/abstract), private method/destructor calls, private(set) and
readonly modification, return type, too few arguments, by-ref unpacking, virtual property
unserialization, DOMXPath::__construct() reentry and XMLReader readonly properties.
ext/filter is covered by #23155.