Re: [SMARTY] Length parameter must be greater than 0
| From: | Mark Rogers | Date: | Tue, 28 Sep 2004 11:12:12 +0000 |
| Subject: | Re: [SMARTY] Length parameter must be greater than 0 | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11824@lists.php.net to get a copy of this message | ||
Messju writes:
> > "Length parameter must be greater than 0" warining is being generated on
> > debug.tpl.html. The file that smarty is looking for is in fact empty,
but it
> > works at work. When I tried this at home, it didn't anymore.
>
> in what file and which line is this error?
> what version of smarty do you use?
> what is debug.tpl.html?
>
> i cannot reproduce this behaviour with your rather vague description.
This is caused by fread($fh,$bytes) where $bytes is zero, eg where the
template file exists but has zero size. The behaviour of fread under this
condition is dependant on the PHP version, not Smarty, although it has been
suggested before that Smarty ought to check that the size is non-zero first.
<IMHO>This is a PHP bug, in that if I chose to read zero bytes from a file
this might be pointless but is not an error that PHP should care about -
particularly when it breaks BC. Google for "length parameter must be greater
than" (with the quotes) to see how many PHP (not Smarty) sites have been
broken by this.
However, given that Smarty uses PHP and it's relatively trivial to find all
filesize() calls and make sure they don't call fread when the filesize is
zero, Smarty ought to handle this better, as an empty template might be
considered valid. Alternatively, supressing errors on calls to fread would
be better than the status quo (but best to test the filesize result).</IMHO>
The simple fix for Sylvain is to make the template non-empy. Something like:
{**}
.. in the debug.tpl.html template (on its own with no whitespace) ought to
be sufficient.
--
Mark Rogers,
More Solutions Ltd :: Tel: 0845 45 89 555