Skip to content

Commit 5060fc2

Browse files
jailssgolemon
authored andcommitted
Fixes #68948 related to a BC break introduced by #68532 fix.
1 parent b152633 commit 5060fc2

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #68948: feof() on temporary streams broken
3+
--FILE--
4+
<?php
5+
6+
$testString = '0123456789';
7+
8+
$stream = fopen("php://memory", "r+");
9+
fwrite($stream, $testString);
10+
rewind($stream);
11+
12+
var_dump(fread($stream, 10));
13+
var_dump(ftell($stream));
14+
var_dump(feof($stream));
15+
16+
rewind($stream);
17+
18+
var_dump(fread($stream, 11));
19+
var_dump(ftell($stream));
20+
var_dump(feof($stream));
21+
22+
?>
23+
--EXPECT--
24+
string(10) "0123456789"
25+
int(10)
26+
bool(false)
27+
string(10) "0123456789"
28+
int(10)
29+
bool(true)
30+

ext/standard/tests/streams/stream_set_chunk_size.phpt

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var_dump(fwrite($f, str_repeat('b', 3)));
3939

4040
echo "should return previous chunk size (1)\n";
4141
var_dump(stream_set_chunk_size($f, 100));
42-
echo "should elicit one read of size 100 (chunk size)\n";
42+
echo "should elicit 3 reads of size 100 (chunk size)\n";
4343
var_dump(strlen(fread($f, 250)));
4444
echo "should elicit one read of size 100 (chunk size)\n";
4545
var_dump(strlen(fread($f, 50)));
@@ -67,13 +67,15 @@ write with size: 1
6767
int(3)
6868
should return previous chunk size (1)
6969
int(1)
70-
should elicit one read of size 100 (chunk size)
70+
should elicit 3 reads of size 100 (chunk size)
7171
read with size: 100
72-
int(100)
73-
should elicit one read of size 100 (chunk size)
7472
read with size: 100
73+
read with size: 100
74+
int(250)
75+
should elicit one read of size 100 (chunk size)
7576
int(50)
7677
should elicit no read because there is sufficient cached data
78+
read with size: 100
7779
int(50)
7880
should elicit 2 writes of size 100 and one of size 50
7981
write with size: 100

main/streams/streams.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size)
710710
}
711711

712712
/* just break anyway, to avoid greedy read */
713-
if (stream->wrapper != &php_plain_files_wrapper) {
713+
if (!stream->wrapper || stream->wrapper->is_url) {
714714
break;
715715
}
716716
}

0 commit comments

Comments
 (0)