php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15089 stat() produces warning instead of error-code.
Submitted: 2002-01-17 16:29 UTC Modified: 2002-06-06 05:35 UTC
Votes:3
Avg. Score:3.0 ± 1.6
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: herp at wildsau dot idv dot uni-linz dot ac dot at Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.1.1 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: herp at wildsau dot idv dot uni-linz dot ac dot at
New email:
PHP Version: OS:

 

 [2002-01-17 16:29 UTC] herp at wildsau dot idv dot uni-linz dot ac dot at
I used stat() to check the existence of files. If the file I check does not
exist, stat() would return FALSE instead of a struct stbuf. This behaviour is also the *documented* behaviour and is how php-4.0 behaves.

Just 15 mins. ago I installed php-4.1.1. Now, stat() on a non-existent
file clutters my html-pages with "Warning: file does not exist". *cough*
Yes, I know that files might not exist, that?s exactly what I use stat()
for, to check the existance of files. Yes, there is "file_exists()", but
why do you output warnings from stat() when returning FALSE is
sufficient? This is one more step away from how one would code
programms in C. Why implement C-like functions (stat(), fstat(), lstat())
when you have to use other non-obvious functions (file_exists())
to do what you could do with the C-like functions. Stay close to the
origins.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-17 16:51 UTC] herp at wildsau dot idv dot uni-linz dot ac dot at
I used stat() to check the existence of files. If the file I check does
    not
    exist, stat() would return FALSE instead of a struct stbuf. This
    behaviour is also the *documented* behaviour and is how php-4.0
    behaves.

    Just 15 mins. ago I installed php-4.1.1. Now, stat() on a non-existent
    file clutters my html-pages with "Warning: file does not exist".
    *cough*
    Yes, I know that files might not exist, that?s exactly what I use
    stat()
    for, to check the existance of files. Yes, there is "file_exists()",
    but
    why do you output warnings from stat() when returning FALSE is
    sufficient? This is one more step away from how one would code
    programms in C. Why implement C-like functions (stat(), fstat(),
    lstat())
    when you have to use other non-obvious functions (file_exists())
    to do what you could do with the C-like functions. Stay close to the
    origins.


Now I have to use *two* functions - first I have to use file_exists(), then I have to use stat(). I am pretty sure that php will execute both calls using the same system-call, that is, stat(2). That?s suboptimal and an overhead and a performance penalty (yes I have *many* files). I just don?t see why the php-engine has to perform the same system-call twice with exactly the same paramters, when one system-call is enough.

I really think this is not good. And since I am in doubt you will ever change that, I am considerung switching to mod_perl.
 [2002-01-18 10:41 UTC] sander@php.net
I agree, it should just return false without a warning.

Reclassified.
 [2002-06-06 05:35 UTC] sander@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC