Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problematic getTrace() recursion

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
conner_bw
Smarty Rookie


Joined: 21 Dec 2007
Posts: 17

PostPosted: Mon Oct 17, 2011 7:22 pm    Post subject: Problematic getTrace() recursion Reply with quote

Hi,

I just upgraded from Smarty 3.0.8 to 3.1.3. This behaviour wasn't happening before. To show the problem, modify the /demo/index.php file to look something like this:

Code:

<?php
/**
* Example Application

* @package Example-application
*/

try {
   
    require('../libs/Smarty.class.php');

    $smarty = new Smarty;

    //$smarty->force_compile = true;
    $smarty->debugging = true;
    $smarty->caching = true;
    $smarty->cache_lifetime = 120;

    $smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
 
    // [... snip ...]

    $smarty->display('index.tpl');
}
catch (Exception $e) {

    $message = 'Error: ';
    $message .= $e->getMessage() . "\n";
    $message .= "File: " . $e->getFile() . "\n";
    $message .= "Line: " . $e->getLine() . "\n\n";
    $message .= "Backtrace: \n" . print_r($e->getTrace(), true) . "\n\n";

    if (!headers_sent()) header('Content-Type: text/plain');
    die($message);
}

?>


Then, make a typo in the template. Example, change:

Code:

{#title#|capitalize}


To:

Code:

{#title#|foo}


Then, reload. The output of getTrace() is over 21300 lines. Sad

This is unhelpful and a resource hog when debugging. It would be good to get the more terse results from 3.0.8 back.

Thank you for your consideration.

Regards,
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Oct 17, 2011 8:07 pm    Post subject: Reply with quote

This is not a bug but caused by a different object structure of Smarty 3.1.

$e->getTrace() does follow every possible object pointer and dump the properties of each pointer found.

I doubt if this kind of output is helpfull at all and you are not better use $e->getTraceAsString() to display just the call stack.
Back to top
View user's profile Send private message
conner_bw
Smarty Rookie


Joined: 21 Dec 2007
Posts: 17

PostPosted: Tue Oct 18, 2011 3:06 pm    Post subject: Reply with quote

U.Tews wrote:

I doubt if this kind of output is helpfull at all and you are not better use $e->getTraceAsString() to display just the call stack.


Terrific, thanks. This will do.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP