[php-src] Issue #12048: Function (usually taking filenames) inconsistently display important arguments in errors
| From: | NattyNarwhal | Date: | Fri, 25 Aug 2023 18:01:30 +0000 |
| Subject: | [php-src] Issue #12048: Function (usually taking filenames) inconsistently display important arguments in errors | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245246@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12048
Author: NattyNarwhal
### Description
If I get the same error with
unlink, chown, and chmod, I only
get the error filename in one:
```
calvin@anika src % /opt/calvin/php/bin/php chmod.php
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
calvin@anika src % cat chmod.php
<?php
unlink("/tmp");
chown("/", "calvin");
chmod("/", 0777);
```
As a real-world example of how annoying this can be, I was assisting someone debug an issue in
WordPress. Because these are traditional PHP errors and not exceptions, and because WordPress
abstracts direct filesystem calls in places like class-wp-filesystem-direct.php,
you're left with a lot of messages with no context and no clue as to what it's trying to
manipulate.
This is caused by the fact that unlink goes to [a
function](https://github.com/php/php-src/blob/master/main/streams/plain_wrapper.c#L1261) that calls
php_error_docref1 with the passed filename, and [other
functions](https://github.com/php/php-src/blob/master/ext/standard/filestat.c#L503) just call
php_error_docref.
Ideally, these should all be made consistent with each other and show important function arguments
as needed.