View previous topic :: View next topic |
Author |
Message |
Spuerhund Smarty Rookie
Joined: 20 Jan 2005 Posts: 16
|
Posted: Fri May 26, 2006 12:15 pm Post subject: sending "Last-Modified" Header can cause E_Warning |
|
|
I am currently using Smarty 2.6.13 and request a small improvement:
In the file "Smarty.class.php" between line 1210 and line 1234 there is something like
Code: | header('Last-Modified: '.$_gmt_mtime); |
for all possible scenarios for a request. It only applies when $caching is enabled and $cache_modified_check is set to 1.
But if - due to a bug or some mistake of the programmer - content output has already startet before, the call of the header() function will cause PHP to throw an Error of level E_WARNING.
Code: | <b>Warning</b>: Cannot modify header information - headers already sent by ... |
This could very easily be fixed by adding
Code: | if (!headers_sent()) { ... } |
around every header() function call.
I know that this doesn't solve the cause of the problem and that a programmer should better know whether he can start outputing content ... but sometimes it may nevertheless happen and a PHP Error message somewhere in the output can (and probably will) make a whole side invalid XHTML (or whatever format you use) and will even cause some browsers (like Firefox) not to render anything but displaying a very ugly and cryptic error message instead (in XHTML 1.1 strict mode). I think this is even worse than a missing "Last-Modified" header in this case, therefore i suggest to fix it in the next version of Smarty.
Spuerhund
Last edited by Spuerhund on Fri May 26, 2006 12:54 pm; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri May 26, 2006 12:25 pm Post subject: Re: sending "Last-Modified" Header can cause E_War |
|
|
Spuerhund wrote: | But if - due to a bug or some mistake of the programmer - content output has already startet before, the call of the header() function will cause PHP to throw an Error of level E_WARNING.
|
then fix said bug or let the programmer fix his mistake. |
|
Back to top |
|
Spuerhund Smarty Rookie
Joined: 20 Jan 2005 Posts: 16
|
Posted: Fri May 26, 2006 12:53 pm Post subject: Re: sending "Last-Modified" Header can cause E_War |
|
|
Spuerhund wrote: | I know that this doesn't solve the cause of the problem and that a programmer should better know whether he can start outputing content ... but sometimes it may nevertheless happen and a PHP Error message somewhere in the output can (and probably will) make a whole side invalid XHTML (or whatever format you use) and will even cause some browsers (like Firefox) not to render anything but displaying a very ugly and cryptic error message instead (in XHTML 1.1 strict mode). I think this is even worse than a missing "Last-Modified" header in this case, therefore i suggest to fix it in the next version of Smarty. |
It is one thing to fix the bug the programmer made. But a different thing to minimize the damage of this mistake and not to &%#& up a whole website because of such a lapse i think. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri May 26, 2006 1:40 pm Post subject: |
|
|
IMHO, that is a bad way to fix this problem. It makes the problem near impossible to track down. This error message informs the programmer that he needs to correct something to get the header working again.
Imagine if PHP silently skipped errors, such as when you apply a string function on an array. You'd spend quite some time figuring out whats wrong! |
|
Back to top |
|
iamsure Smarty Rookie
Joined: 02 Feb 2005 Posts: 22
|
Posted: Sat May 27, 2006 7:47 am Post subject: |
|
|
[edited]
Last edited by iamsure on Thu Jul 27, 2006 12:37 am; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
iamsure Smarty Rookie
Joined: 02 Feb 2005 Posts: 22
|
Posted: Sat May 27, 2006 9:02 am Post subject: |
|
|
[edited]
Last edited by iamsure on Thu Jul 27, 2006 12:37 am; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat May 27, 2006 9:35 am Post subject: |
|
|
iamsure wrote: | That option gives two responses: Either give the (incorrect!) last modified date header, OR, give an incorrect 304 not-modified header. |
wrong. with $smarty->cache_modified_check = false (the default) no header at all are sent.
and BTW: why don't you tell us *what* is wrong with these headers? |
|
Back to top |
|
|