Jeff-Lewis / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

Warning thrown when activating SMARTY_DEBUG from URL. #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add SMARTY_DEBUG=on to URL.

What is the expected output? What do you see instead?

New window with debug window.
No warning in error log.

What version of the product are you using? On what operating system?

Smarty V3.1.14, CentOS.

Please provide any additional information below.

The warning only appears when debugging.

Normally this warning is when you echo content and then try to set headers.

[29-Jul-2013 12:18:10 Europe/London] PHP Warning:  Cannot modify header 
information - headers already sent by (output started at 
/mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smar
ty-3.1.14/sysplugins/smarty_internal_templatebase.php:340) in 
/mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smar
ty-3.1.14/sysplugins/smarty_internal_templatebase.php on line 97

As it is Smarty that has output the code that is causing the warning, I'm not 
exactly sure what to do about it.

Original issue reported on code.google.com by RQuadling@gmail.com on 29 Jul 2013 at 11:27

GoogleCodeExporter commented 9 years ago
You must have set
$smarty->debugging_ctrl = 'URL';
after some $smarty->display(..); call.

In such case 'SMARTY_DEBUG=on' is not possible as it tries to set a cookie 
after output was already generated. 

Just use 'SMARTY_DEBUG' on the URL not using a cookie for permanent debugging,
or move $smarty->debugging_ctrl = 'URL'; to the top of your script.

Original comment by Uwe.Tews@googlemail.com on 29 Jul 2013 at 12:14

GoogleCodeExporter commented 9 years ago
Hi.

Your suggestions doesn't mirror my code or experience.

We have a wrapper class that sets up the debugging availability for our dev 
setups (so debugging is not available on the live setup).

This happens very early and provides the $o_Template instance.

At the very end of the controller, we have the one and only 
$o_Template->display(); call.

In adding some debugging to Smarty, specifically a debug_backtrace() at the 
line numbers reported, it seems that the cookie is attempting to be set twice. 
Once before the display and once as part of the debugging. Unfortunately, in 
between the two, the main template body is echo'd.

[29/07/2013 13:56:37]  Trying to set cookie.
Array
(
    [0] => Array
        (
            [file] => /mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smarty-3.1.14/sysplugins/smarty_internal_templatebase.php
            [line] => 376
            [function] => fetch
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

    [1] => Array
        (
            [file] => /mnt/newbuild/trunk/www/index.php
            [line] => 279
            [function] => display
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

)

[29/07/2013 13:56:37]  Output sent.
Array
(
    [0] => Array
        (
            [file] => /mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smarty-3.1.14/sysplugins/smarty_internal_templatebase.php
            [line] => 376
            [function] => fetch
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

    [1] => Array
        (
            [file] => /mnt/newbuild/trunk/www/index.php
            [line] => 279
            [function] => display
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

)

[29/07/2013 13:56:37]  Trying to set cookie.
Array
(
    [0] => Array
        (
            [file] => /mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smarty-3.1.14/sysplugins/smarty_internal_debug.php
            [line] => 135
            [function] => fetch
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

    [1] => Array
        (
            [file] => /mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smarty-3.1.14/sysplugins/smarty_internal_templatebase.php
            [line] => 346
            [function] => display_debug
            [class] => Smarty_Internal_Debug
            [type] => ::
        )

    [2] => Array
        (
            [file] => /mnt/newbuild/trunk/includes/frontend/site_includes/classes/Smarty/Releases/Smarty-3.1.14/sysplugins/smarty_internal_templatebase.php
            [line] => 376
            [function] => fetch
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

    [3] => Array
        (
            [file] => /mnt/newbuild/trunk/www/index.php
            [line] => 279
            [function] => display
            [class] => Smarty_Internal_TemplateBase
            [type] => ->
        )

)

As you can see, the base call is from index.php at line 279. From then on, it 
is all Smarty.

Original comment by RQuadling@gmail.com on 29 Jul 2013 at 1:12

GoogleCodeExporter commented 9 years ago
The code in our wrapper class for the debugging capabilities ...

    public function __construct()
    {

        parent::__construct();

        $this->debugging                     = False;
        $this->debugging_ctrl                = Site::isLive() ? 'None' : 'URL';

    }

Additional code exists dealing with our plugin location and various settings 
regarding cache directory, etc.

Original comment by RQuadling@gmail.com on 29 Jul 2013 at 1:16

GoogleCodeExporter commented 9 years ago
Yes, you have been right. For some reasion the warning was not shown on my 
system.
The fix is now in the SVN trunk and will later be included in 3.1.15.

thank's for bringing this up.

Original comment by Uwe.Tews@googlemail.com on 29 Jul 2013 at 2:00