Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

realpath() with empty path should return false #10101

Closed
mvorisek opened this issue Dec 14, 2022 · 4 comments
Closed

realpath() with empty path should return false #10101

mvorisek opened this issue Dec 14, 2022 · 4 comments

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Dec 14, 2022

Description

All file functions, incl. dir functions like file_exists() or is_dir() return false when the input is empty.

One exception is realpath(), it returns the current directory when '' is given.

The reason is probably the way how realpath() is written, the path is probably checked if absolute and if not, it is appended to the current directory, even if empty.

After a fix, I expect realpath('') to return false.

It is probably not a bug, as documented so [1], but I propose this to be fixed to be consistent with other file functions.

[1] php/doc-en@5ca36de

@stramunin
Copy link

A small note. The above functions are boolean unlike realpath.

I just looked at how the standard function works and it returns an error on empty input. Maybe it's better to make it close to the implementation in C.

@hormus
Copy link

hormus commented Dec 15, 2022

@Girgias
Copy link
Member

Girgias commented Dec 15, 2022

At best making those function throw a ValueError by first deprecating this behaviour makes more sense than this arbitrary change.

@iluuu1994
Copy link
Member

I'm closing this, this should be discussed on the list.

@iluuu1994 iluuu1994 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants