-
Notifications
You must be signed in to change notification settings - Fork 731
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
filesize() to return size of symlink rather than the target file size #3598
Comments
I cannot reproduce with php 8.3.6 nor with 8.3.8, would you have a reproducer or give more details regarding your case ? |
I also have this issue on another server with centos 7 and php 8.3.8. |
There might be more to it. e.g. are you getting a symlink from a shared (virtualised ?) folder ? network mountpoint ? |
Nope it's a symlink to a file in the same folder. |
It might thus
|
|
sure ... looking at php_stat, it seems to behave "as expected', now I m torn between bug and "feature request to change longtime behavior". |
Yeah I didn't expect it to behave like this, I thought filesize would show size of the file supplied and not the target file of a symlink, would've made more sense to do filesize(realpath()) if target file size was needed🤔 Well probably because in most cases filesize of a symlink would be irrelevant😅 |
I don't think we can change this. I would not consider it as a bug. This would require RFC to get changed. |
@RV7PR, are you interested in pursuing the RFC process? |
@cmb69 Not really... maybe we should just add a note for filesize() and SplFileInfo::getSize() specifiying that it always uses the target file of a symlink and if the filesize is needed for a symlink that lstat()['size'] should be used and that if target file does not exists anymore it generates a warning. |
Well, I'm fine with transferring this to doc-en (so the documentation could be updated). Any objections? |
I'm okay with that |
Description
filesize() returns false on symlink with warning:
filesize(): stat failed for {filename}
I have to use lstat($symlink)['size'] to get size of a symlink
PHP Version
PHP 8.3.8
Operating System
CentOS Stream release 9
Edit by @cmb69: see #3598 (comment) for the latest suggestion to improve the documentation.
The text was updated successfully, but these errors were encountered: