You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fopen('safe://' . 'some_file_path', 'a');
results in: stream_copy_to_stream(): Read of 8192 bytes failed with errno=9 Bad file descriptor
Expected Behavior
fopen('safe://' . some_file_path, 'a');
opens the file
file didn't exist on the given path, so it should be created
Possible Solution
SafeStream.php:114 if (stream_copy_to_stream($this->handle, $this->tempHandle) !== $stat['size']) {
tries to read from file $this->handle opend with readonly mode 'x'
this looks like proper behavior of PHP - not a bug in PHP: https://bugs.php.net/bug.php?id=78482
if the file would be open with flag 'x+', everything works just fine:
SafeStream.php:89 if ($this->checkAndLock($this->handle = @fopen($path, 'x' . $flag, $use_path), LOCK_EX)) {
if $flag would be '+' -- works fine, but $flag is empty string ''
The text was updated successfully, but these errors were encountered:
forgie1
added a commit
to forgie1/safe-stream
that referenced
this issue
Jun 2, 2021
Version: 2.4.1
Ubuntu 20.04.2 LTS
PHP 8.0.5
Bug Description
fopen('safe://' . 'some_file_path', 'a');
results in:
stream_copy_to_stream(): Read of 8192 bytes failed with errno=9 Bad file descriptor
Expected Behavior
fopen('safe://' . some_file_path, 'a');
opens the file
file didn't exist on the given path, so it should be created
Possible Solution
SafeStream.php:114
if (stream_copy_to_stream($this->handle, $this->tempHandle) !== $stat['size']) {
tries to read from file
$this->handle
opend with readonly mode'x'
this looks like proper behavior of PHP - not a bug in PHP:
https://bugs.php.net/bug.php?id=78482
if the file would be open with flag 'x+', everything works just fine:
SafeStream.php:89
if ($this->checkAndLock($this->handle = @fopen($path, 'x' . $flag, $use_path), LOCK_EX)) {
if
$flag
would be'+'
-- works fine, but$flag
is empty string''
The text was updated successfully, but these errors were encountered: