Re: [SMARTY] Length parameter must be greater than 0

From: Date: Tue, 28 Sep 2004 11:24:24 +0000
Subject: Re: [SMARTY] Length parameter must be greater than 0
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11825@lists.php.net to get a copy of this message
On Tue, Sep 28, 2004 at 12:12:12PM +0100, Mark Rogers wrote: > 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. this is already fixed in smarty for quite some time. but silvain is using Smarty-2.5.0 . once i got this flux compensator running, i'll go back in time and fix that in Smarty-2.5.0 which was released much earlier than this erm feature was introduced into php. regards messju > -- > Mark Rogers, > More Solutions Ltd :: Tel: 0845 45 89 555

« previous php.smarty.general (#11825) next »