Skip to content

Function (usually taking filenames) inconsistently display important arguments in errors #12048

Open
@NattyNarwhal

Description

@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 that calls php_error_docref1 with the passed filename, and other functions just call php_error_docref.

Ideally, these should all be made consistent with each other and show important function arguments as needed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions