When a built-in PHP function raises a warning, the message names the function but almost never shows what you passed to it. A log tells you chown() failed, but not which file it failed on. This RFC from Calvin Buckley adds an INI setting, error_include_args, that puts the actual arguments in the message.
Before and after#
Take this script:
unlink("/tmp");
chown("/", "calvin");
chmod("/", 0777);
Today you get:
Warning: unlink(/tmp): Operation not permitted in /Users/calvin/src/chmod.php on line 3
Warning: chown(): Operation not permitted in /Users/calvin/src/chmod.php on line 4
Warning: chmod(): Operation not permitted in /Users/calvin/src/chmod.php on line 5
With the setting on:
Warning: unlink('/tmp'): Operation not permitted in /Users/calvin/src/chmod.php on line 3
Warning: chown('/', 'calvin'): Operation not permitted in /Users/calvin/src/chmod.php on line 4
Warning: chmod('/', 511): Operation not permitted in /Users/calvin/src/chmod.php on line 5
How it stays safe#
It reuses the code that prints arguments in exception backtraces, so it follows the same rules:
zend.exception_string_param_max_len truncates long strings, so logs don't fill up.
- Parameters marked with
#[\SensitiveParameter] are redacted, so passwords passed to functions like password_hash() won't show up.
It only applies to built-in functions. Errors you raise yourself with trigger_error() don't change.
The RFC's own benchmark ran a failing call in a tight loop, and it was slower with the setting on: about 1.8 seconds versus 1.1 for a million errors. The author notes that most code doesn't raise errors that often.
What it means for existing code#
Nothing changes unless you turn it on, because the vote kept the default at 0. If you enable it, the error text changes, so tools that parse PHP error logs or code in set_error_handler that reads messages may need updates. Extensions should mark sensitive parameters with the attribute.