I've just encountered again. If you want to use a
template file that's 0 bytes large you get an error
like this one:
Warning: fread(): Length parameter must be greater than
0. in
/home/rkiesler/var/www/kiesler.at/pt/forum/lib/pear/HTML/Template/IT.php
on line 956
0 byte template files can be useful for example if you
want to hide some part of a module, I do that quite
often. A workaround was to simply disable warnings. But
I found a better solution now.
I understand that the affected classes are 3rd party
(PEAR), still they are shipped with phpWebSite.
Probably someone should send that fix to the maintainer
of the PEAR classes to.
I've only added a check for (filesize($filename) === 0)
here, the lib/pear/HTML/Template/IT.php is from
phpWebSite 0.10.2:
/**
* Reads a file from disk and returns its content.
* @param string Filename
* @return string Filecontent
*/
function getFile($filename) {
if ("/" == $filename{0} && "/" ==
substr($this->fileRoot, -1))
$filename = substr($filename, 1);
$filename = $this->fileRoot . $filename;
if (!($fh = @fopen($filename, "r"))) {
$this->err[] = PEAR::raiseError(
$this->errorMessage(IT_TPL_NOT_FOUND) .
': "' .$filename .'"',
IT_TPL_NOT_FOUND
);
return "";
}
if(filesize($filename) === 0)
return("");
$content = fread($fh, filesize($filename));
fclose($fh);
return preg_replace(
"#<!-- INCLUDE (.*) -->#ime",
"\$this->getFile('\\1')", $content
);
} // end func getFile
Logged In: YES
user_id=722742
This has now been fixed in the PEAR class. See http://pear.php.net/bugs/
bug.php?id=6084
Closing here.