dont throw errors on double close in stream wrapper

This commit is contained in:
Robin Appelman 2021-03-12 16:48:22 +01:00
commit 93bce47220
2 changed files with 14 additions and 1 deletions

View file

@ -92,7 +92,9 @@ abstract class Wrapper extends WrapperHandler implements File, Directory {
}
public function stream_close() {
return fclose($this->source);
if (is_resource($this->source)) {
return fclose($this->source);
}
}
public function dir_readdir() {

View file

@ -140,4 +140,15 @@ abstract class WrapperTest extends TestCase {
rewinddir($wrapped);
$this->assertSame($content[0], readdir($wrapped));
}
public function testDoubleClose() {
$source = fopen('php://temp', 'r+');
rewind($source);
$wrapped = $this->wrapSource($source);
fclose($source);
fclose($wrapped);
$this->assertFalse(is_resource($source));
}
}