This repository was archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
This repository was archived by the owner on Oct 16, 2019. It is now read-only.
file_exists Always return true even if file does not exist #50
Copy link
Copy link
Open
Description
The php function file_exists() uses the the stream wrapper function url_stat()
Unfortunately \ZendService\Amazon\S3\Stream function url_stat always return a value even if the file does not exists
It means that everytime you uses file_exists() it always return true .
I only tested using FakeS3 - which simulate an amazon s3 "server" https://github.com/jubos/fake-s3
So it might be related but looking at the url_stat function I am pretty certain this is not caused by FakeS3
/**
* Return array of URL variables
*
* @param string $path
* @param integer $flags
* @return array
*/
public function url_stat($path, $flags)
{
$stat = array();
$stat['dev'] = 0;
$stat['ino'] = 0;
$stat['mode'] = 0777;
$stat['nlink'] = 0;
$stat['uid'] = 0;
$stat['gid'] = 0;
$stat['rdev'] = 0;
$stat['size'] = 0;
$stat['atime'] = 0;
$stat['mtime'] = 0;
$stat['ctime'] = 0;
$stat['blksize'] = 0;
$stat['blocks'] = 0;
$name = $this->_getNamePart($path);
if(($slash = strchr($name, '/')) === false || $slash == strlen($name)-1) {
/* bucket */
$stat['mode'] |= 040000;
} else {
$stat['mode'] |= 0100000;
}
$info = $this->_getS3Client($path)->getInfo($name);
if (!empty($info)) {
$stat['size'] = $info['size'];
$stat['atime'] = time();
$stat['mtime'] = $info['mtime'];
}
return $stat;
}
I believe it should be
public function url_stat($path, $flags) {
$stat = array();
$stat['dev'] = 0;
$stat['ino'] = 0;
$stat['mode'] = 0777;
$stat['nlink'] = 0;
$stat['uid'] = 0;
$stat['gid'] = 0;
$stat['rdev'] = 0;
$stat['size'] = 0;
$stat['atime'] = 0;
$stat['mtime'] = 0;
$stat['ctime'] = 0;
$stat['blksize'] = 0;
$stat['blocks'] = 0;
$name = $this->_getNamePart($path);
if (($slash = strchr($name, '/')) === false || $slash == strlen($name) - 1) {
/* bucket */
$stat['mode'] |= 040000;
} else {
$stat['mode'] |= 0100000;
}
$info = $this->_getS3Client($path)->getInfo($name);
if (!empty($info)) {
$stat['size'] = $info['size'];
$stat['atime'] = time();
$stat['mtime'] = $info['mtime'];
return $stat;
}
return false;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels