dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "rdbms: better normalize and document constructor $params in Database"
[lhc/web/wiklou.git]
/
includes
/
Rest
/
StringStream.php
diff --git
a/includes/Rest/StringStream.php
b/includes/Rest/StringStream.php
index
18fb6b1
..
3ad0d96
100644
(file)
--- a/
includes/Rest/StringStream.php
+++ b/
includes/Rest/StringStream.php
@@
-30,12
+30,7
@@
class StringStream implements CopyableStreamInterface {
}
public function copyToStream( $stream ) {
}
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() {
}
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;
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 );
}
} 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;
public function getContents() {
if ( $this->offset === 0 ) {
$ret = $this->contents;
+ } elseif ( $this->offset >= strlen( $this->contents ) ) {
+ $ret = '';
} else {
$ret = substr( $this->contents, $this->offset );
}
} else {
$ret = substr( $this->contents, $this->offset );
}