Skip to content

stat() calls are missing warnings #2999

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

Closed
SiebelsTim opened this issue Jun 20, 2014 · 4 comments
Closed

stat() calls are missing warnings #2999

SiebelsTim opened this issue Jun 20, 2014 · 4 comments
Assignees

Comments

@SiebelsTim
Copy link
Contributor

PHP says to raise a warning on bad stat() calls in C
(https://github.com/php/php-src/blob/af6c11c5f060870d052a2b765dc634d9e47d0f18/ext/standard/filestat.c#L909)

PHP's manual agrees on this:
http://de3.php.net/manual/en/function.is-dir.php#refsect1-function.is-dir-errors (and many others)

However I could not get a warning on is_dir:
http://3v4l.org/kG9PX

Tried to fix with

diff --git a/hphp/runtime/ext/ext_file.cpp b/hphp/runtime/ext/ext_file.cpp
index 37c932c..411d014 100644
--- a/hphp/runtime/ext/ext_file.cpp
+++ b/hphp/runtime/ext/ext_file.cpp
@@ -156,6 +156,7 @@ static int statSyscall(
     std::string realpath = StatCache::realpath(fullpath.data());
     // realpath will return an empty string for nonexistent files
     if (realpath.empty()) {
+      raise_warning("stat failed for %s", path.c_str());
       return ENOENT;
     }
     auto translatedPath = canUseFileCache ?
SiebelsTim added a commit to SiebelsTim/hhvm that referenced this issue Jun 20, 2014
This could be pulled in without the test.
However the test will fail because no warnings are thrown (See facebook#2999)

This tries to fix zend/bad/ext/spl/tests/DirectoryIterator_getInode_error.php
@JoelMarcey JoelMarcey self-assigned this Jun 23, 2014
@paulbiss
Copy link
Contributor

paulbiss commented Sep 9, 2014

Looks like there had been a (now abandoned) PR for this. @JoelMarcey are you looking into it?

@SiebelsTim
Copy link
Contributor Author

@paulbiss Do you mean my PR #3000? That was only related to it, not fixing this.

@paulbiss
Copy link
Contributor

paulbiss commented Sep 9, 2014

Ah, okay.

@Majkl578
Copy link
Contributor

Majkl578 commented Oct 1, 2014

However I could not get a warning on is_dir

Because is_dir is a testing function, it should not throw warnings if target does not exist. Even your 3v4l snippet does not throw a warning in PHP.

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

4 participants