Remove Revision::getRevisionText from ApiQueryDeletedrevs
[lhc/web/wiklou.git] / includes / Rest / StringStream.php
index 18fb6b1..3ad0d96 100644 (file)
@@ -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 );
                }