[ticket/15305] Fix streams

PHPBB3-15305
This commit is contained in:
Rubén Calvo 2017-08-07 13:19:05 +02:00
parent 9b7a5fc2a5
commit cd2bae63cb
2 changed files with 4 additions and 4 deletions

View file

@ -201,7 +201,7 @@ class local implements adapter_interface
*/ */
public function read_stream($path) public function read_stream($path)
{ {
$stream = @fopen($path, 'rb'); $stream = @fopen($this->root_path . $path, 'rb');
if (!$stream) if (!$stream)
{ {
@ -221,7 +221,7 @@ class local implements adapter_interface
throw new exception('STORAGE_FILE_EXISTS', $path); throw new exception('STORAGE_FILE_EXISTS', $path);
} }
$stream = @fopen($path, 'w+b'); $stream = @fopen($this->root_path . $path, 'w+b');
if (!$stream) if (!$stream)
{ {

View file

@ -106,7 +106,7 @@
public function test_read_stream() public function test_read_stream()
{ {
file_put_contents($this->path . 'file.txt', ''); file_put_contents($this->path . 'file.txt', '');
$stream = $this->adapter->read_stream($this->path . 'file.txt'); $stream = $this->adapter->read_stream('file.txt');
$this->assertTrue(is_resource($stream)); $this->assertTrue(is_resource($stream));
fclose($stream); fclose($stream);
unlink($this->path . 'file.txt'); unlink($this->path . 'file.txt');
@ -116,7 +116,7 @@
{ {
file_put_contents($this->path . 'file.txt', 'abc'); file_put_contents($this->path . 'file.txt', 'abc');
$stream = fopen($this->path . 'file.txt', 'r'); $stream = fopen($this->path . 'file.txt', 'r');
$this->adapter->write_stream($this->path . 'file2.txt', $stream); $this->adapter->write_stream('file2.txt', $stream);
fclose($stream); fclose($stream);
$this->assertEquals(file_get_contents($this->path . 'file2.txt'), 'abc'); $this->assertEquals(file_get_contents($this->path . 'file2.txt'), 'abc');
unlink($this->path . 'file.txt'); unlink($this->path . 'file.txt');