ID: 35918
Updated by: [EMAIL PROTECTED]
Reported By: cpuidle at gmx dot de
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: WinXP SP2
PHP Version: 5.1.1
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2006-01-06 16:07:22] cpuidle at gmx dot de
Description:
------------
After using stream_wrapper_register on php 5.1.1, fread is suddenly
limited to 8K block size when reading local(!) files.
This behaviour is
a) not documentated
b) does not happen with PHP 5.0.5
c) not consistent (depending on use of stream_wrapper_register)
I had previously opened bug 35859, but did not receive an answer after
the details had been discovered.
Thanks,
Andi
Reproduce code:
---------------
<?php
class VariableStream {
var $position, $varname;
function stream_open($path, $mode, $options, &$opened_path) {
$url = parse_url($path);
$this->varname = $url['host'];
$this->position = 0;
return true;
}
function stream_read($count) {
$ret = substr($GLOBALS[$this->varname],
$this->position,$count);
$this->position += strlen($ret);
return $ret;
}
function stream_eof() {
return $this->position >= strlen($GLOBALS[$this->varname]);
}
function stream_stat() {
return array('size' => strlen($GLOBALS[$this->varname]));
}
function url_stat() {
return array();
}
}
function read($filename) {
if (file_exists($filename) && ($fd = @fopen($filename, 'rb'))) {
$size = filesize($filename);
$contents = fread($fd, $size);
}
echo("\$filename $filename: \$size: $size
strlen(\$contents):".strlen($contents)."<br/>");
}
// local file
$filename = 'templates/elegant/show.tpl';
// will read entire file
read($filename);
stream_wrapper_register('var', 'VariableStream');
// will only read 8K
read($filename);
?>
Expected result:
----------------
$filename templates/elegant/show.tpl: $size: 9520 strlen($contents):
9520
$filename templates/elegant/show.tpl: $size: 9520 strlen($contents):
9520 (!!)
Actual result:
--------------
$filename templates/elegant/show.tpl: $size: 9520 strlen($contents):
9520
$filename templates/elegant/show.tpl: $size: 9520 strlen($contents):
8192 (!!)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35918&edit=1