--- /dev/null
+--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)
+
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)));
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
}
/* just break anyway, to avoid greedy read */
- if (stream->wrapper != &php_plain_files_wrapper) {
+ if (!stream->wrapper || stream->wrapper->is_url) {
break;
}
}