diff options
author | Simon JAILLET <sjaillet@gmail.com> | 2017-05-06 16:29:34 +0200 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2017-11-06 17:34:42 -0500 |
commit | 5060fc2349447fe17b59184a0147e73feb0e7a30 (patch) | |
tree | 78d50615a620880e847c95f84e4506844c071bde | |
parent | b152633ecb2030e2de1f83d2d42193185ea1bc21 (diff) | |
download | php-git-5060fc2349447fe17b59184a0147e73feb0e7a30.tar.gz |
Fixes #68948 related to a BC break introduced by #68532 fix.
-rw-r--r-- | ext/standard/tests/streams/bug68948.phpt | 30 | ||||
-rw-r--r-- | ext/standard/tests/streams/stream_set_chunk_size.phpt | 10 | ||||
-rw-r--r-- | main/streams/streams.c | 2 |
3 files changed, 37 insertions, 5 deletions
diff --git a/ext/standard/tests/streams/bug68948.phpt b/ext/standard/tests/streams/bug68948.phpt new file mode 100644 index 0000000000..7ce9d7ad03 --- /dev/null +++ b/ext/standard/tests/streams/bug68948.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #68948: feof() on temporary streams broken +--FILE-- +<?php + +$testString = '0123456789'; + +$stream = fopen("php://memory", "r+"); +fwrite($stream, $testString); +rewind($stream); + +var_dump(fread($stream, 10)); +var_dump(ftell($stream)); +var_dump(feof($stream)); + +rewind($stream); + +var_dump(fread($stream, 11)); +var_dump(ftell($stream)); +var_dump(feof($stream)); + +?> +--EXPECT-- +string(10) "0123456789" +int(10) +bool(false) +string(10) "0123456789" +int(10) +bool(true) + diff --git a/ext/standard/tests/streams/stream_set_chunk_size.phpt b/ext/standard/tests/streams/stream_set_chunk_size.phpt index ce272519c4..88f4897e93 100644 --- a/ext/standard/tests/streams/stream_set_chunk_size.phpt +++ b/ext/standard/tests/streams/stream_set_chunk_size.phpt @@ -39,7 +39,7 @@ var_dump(fwrite($f, str_repeat('b', 3))); echo "should return previous chunk size (1)\n"; var_dump(stream_set_chunk_size($f, 100)); -echo "should elicit one read of size 100 (chunk size)\n"; +echo "should elicit 3 reads of size 100 (chunk size)\n"; var_dump(strlen(fread($f, 250))); echo "should elicit one read of size 100 (chunk size)\n"; var_dump(strlen(fread($f, 50))); @@ -67,13 +67,15 @@ write with size: 1 int(3) should return previous chunk size (1) int(1) -should elicit one read of size 100 (chunk size) +should elicit 3 reads of size 100 (chunk size) read with size: 100 -int(100) -should elicit one read of size 100 (chunk size) read with size: 100 +read with size: 100 +int(250) +should elicit one read of size 100 (chunk size) int(50) should elicit no read because there is sufficient cached data +read with size: 100 int(50) should elicit 2 writes of size 100 and one of size 50 write with size: 100 diff --git a/main/streams/streams.c b/main/streams/streams.c index dab8505d41..b1099b6fcc 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -710,7 +710,7 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size) } /* just break anyway, to avoid greedy read */ - if (stream->wrapper != &php_plain_files_wrapper) { + if (!stream->wrapper || stream->wrapper->is_url) { break; } } |