mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 05:18:52 +00:00
[ticket/15305] Simulate streams if they are not implemented
PHPBB3-15305
This commit is contained in:
parent
c93c2d4007
commit
b9e22b4da4
1 changed files with 27 additions and 2 deletions
|
@ -160,7 +160,22 @@ class storage
|
||||||
*/
|
*/
|
||||||
public function read_stream($path)
|
public function read_stream($path)
|
||||||
{
|
{
|
||||||
$this->get_adapter()->read_stream($path);
|
$stream = null;
|
||||||
|
$adapter = $this->get_adapter();
|
||||||
|
|
||||||
|
if ($adapter instanceof stream_interface)
|
||||||
|
{
|
||||||
|
$stream = $adapter->read_stream($path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Simulate the stream
|
||||||
|
$stream = tmpfile();
|
||||||
|
fwrite($stream, $adapter->get_contents($path));
|
||||||
|
rewind($stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,6 +188,16 @@ class storage
|
||||||
*/
|
*/
|
||||||
public function write_stream($path, $resource)
|
public function write_stream($path, $resource)
|
||||||
{
|
{
|
||||||
$this->get_adapter()->write_stream($path, $resource);
|
$adapter = $this->get_adapter();
|
||||||
|
|
||||||
|
if ($adapter instanceof stream_interface)
|
||||||
|
{
|
||||||
|
$adapter>write_stream($path, $resource);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Simulate the stream
|
||||||
|
$adapter->put_contents($path, stream_get_contents($resource));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue