ZF-12250: file_exists() always returns true when using stream wrapper Zend_Service_Amazon_S3_Stream


My understanding is that StreamWrapperClass::url_stat() should return false just like stat() when a file doesn't exist.

When given a nonexistent file path, Zend_Service_Amazon_S3_Stream::url_stat() returns an array with all values set to 0 except 'mode', causing the wrapped file_exists() to return true.


You can't imagine how much time it took for me to trace a big issue up to this issue!

I've made a simple fix, but I'm unsure what the policy is for contributing, and since it's such a small change, I'll post it here for the assignee to validate and apply, if he so wants:

@@ -460,9 +460,13 @@ class Zend_Service_Amazon_S3_Stream
             $stat['size']  = $info['size'];
             $stat['atime'] = time();
             $stat['mtime'] = $info['mtime'];
+            return $stat;
+        }
+        else{
+            return false;
-        return $stat;