For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > September 2004 > Re: [SMARTY] Length parameter must be greater than 0









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2004-09-26, 3:57 pm

On Sat, Sep 25, 2004 at 02:50:30AM +0200, Sylvain Girard wrote:
> Hi,
>
>
>
> "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.

greetings
messju

> Best regards,
>
> Sylvain Girard
>
>
>
> GVG Design
>
> www: <http://www.gvg-design.be> http://www.gvg-design.be
>
> email: <mailto:s.girard@gvg-design.be> s.girard@gvg-design.be
>
> tel: +32486282435

Mark Rogers

2004-09-28, 9:28 pm

Messju writes:
but it[color=darkred]
>
> 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
Messju Mohr

2004-09-28, 9:28 pm

On Tue, Sep 28, 2004 at 12:12:12PM +0100, Mark Rogers wrote:
> Messju writes:
> but it
>
> 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

Mark Rogers

2004-09-28, 9:28 pm

Messju writes:
> 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.


Ah, I thought it was but checked on my server (which is running 2.6.3) and
it didn't work exactly as Silvain reported.

It seems that the virtual host I checked on is actually running 2.6.0-RC2 -
doh!

When you do get the flux compensator running (or if you need a beta tester,
since I don't need to go back more than an hour) I'll delete the previous
message.

--
Mark Rogers,
More Solutions Ltd :: Tel: 0845 45 89 555
Jochem Maas

2004-09-28, 9:28 pm


>
> 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.
>


messju - that will never work! your working on the wrong part:

http://www.fact-index.com/f/fl/flux_capacitor.html

;-)

> regards
> messju
>
>
>
>

Messju Mohr

2004-09-28, 9:28 pm

On Tue, Sep 28, 2004 at 03:32:57PM +0200, Jochem Maas wrote:
>
>
> messju - that will never work! your working on the wrong part:
>
> http://www.fact-index.com/f/fl/flux_capacitor.html


damn. i only knew the german version. and translated that back.
:)
[color=darkred]
> ;-)
>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com