X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FRest%2FStringStream.php;h=3ad0d9608156aecbe8517acd36bb65cf31527797;hb=9283760f340c6971d748fb574a35453fa7928807;hp=18fb6b1812d544796e7b2d9456bf70218248ab70;hpb=7b3631abc85ff63947908022803b245bcefafd49;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Rest/StringStream.php b/includes/Rest/StringStream.php index 18fb6b1812..3ad0d96081 100644 --- a/includes/Rest/StringStream.php +++ b/includes/Rest/StringStream.php @@ -30,12 +30,7 @@ class StringStream implements CopyableStreamInterface { } public function copyToStream( $stream ) { - if ( $this->offset !== 0 ) { - $block = substr( $this->contents, $this->offset ); - } else { - $block = $this->contents; - } - fwrite( $stream, $block ); + fwrite( $stream, $this->getContents() ); } public function __toString() { @@ -116,6 +111,8 @@ class StringStream implements CopyableStreamInterface { public function read( $length ) { if ( $this->offset === 0 && $length >= strlen( $this->contents ) ) { $ret = $this->contents; + } elseif ( $this->offset >= strlen( $this->contents ) ) { + $ret = ''; } else { $ret = substr( $this->contents, $this->offset, $length ); } @@ -126,6 +123,8 @@ class StringStream implements CopyableStreamInterface { public function getContents() { if ( $this->offset === 0 ) { $ret = $this->contents; + } elseif ( $this->offset >= strlen( $this->contents ) ) { + $ret = ''; } else { $ret = substr( $this->contents, $this->offset ); }