From: Tim Starling Date: Fri, 14 Jun 2019 07:00:11 +0000 (+1000) Subject: Fix HHVM StringStream test errors X-Git-Tag: 1.34.0-rc.0~1407 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=d0e2acd89ac49bf1df60e0a8d5ab5872427ccb86;p=lhc%2Fweb%2Fwiklou.git Fix HHVM StringStream test errors Change-Id: I3eebd14db7157bb423ee88af7b49d92f628bc771 --- diff --git a/includes/Rest/StringStream.php b/includes/Rest/StringStream.php index 10ec42dbf0..3ad0d96081 100644 --- a/includes/Rest/StringStream.php +++ b/includes/Rest/StringStream.php @@ -30,13 +30,7 @@ class StringStream implements CopyableStreamInterface { } public function copyToStream( $stream ) { - if ( $this->offset !== 0 ) { - $block = substr( $this->contents, $this->offset ); - } else { - $block = $this->contents; - } - $this->offset = strlen( $this->contents ); - fwrite( $stream, $block ); + fwrite( $stream, $this->getContents() ); } public function __toString() { @@ -117,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 ); } @@ -127,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 ); }