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

Incorrect line number in error messages

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
SLX
Smarty Rookie


Joined: 19 Nov 2009
Posts: 11
Location: Wroclaw, Poland

PostPosted: Tue Nov 24, 2009 4:20 pm    Post subject: Incorrect line number in error messages Reply with quote

When I make a simple error in template file, the smarty give me wrong number of line in which the error occured. I think here is mistake:

Code:
file: /sysplugins/smarty_internal_templatecompilerbase.php:244

$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '"  on line ' . $line . ' "' . $match[$line-1] . '" ';


It should be:
Code:
$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '"  on line ' . ($line-1) . ' "' . $match[$line-1] . '" ';
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Nov 24, 2009 7:37 pm    Post subject: Reply with quote

No this code is not the problem.

There are some cases when the parser has switched to the next line because of a lookahead token.

Could you please provide the section of the template which did cause the problem?
Back to top
View user's profile Send private message
SLX
Smarty Rookie


Joined: 19 Nov 2009
Posts: 11
Location: Wroclaw, Poland

PostPosted: Thu Nov 26, 2009 12:03 pm    Post subject: Reply with quote

I see that problem is more complicated. I was created test page, and notice that it is not next line, but next smarty tag.

Here is index.tpl:
Code:
Some text on line 1<br>
Some text on line 2<br>
This is line 3 {NonExistentPlugin}<br>
Some text on line 4<br>
Some text on line 5<br>
{assign var='abc' value='def'}
Some text on line 7<br>


I get this Exception:
Quote:
Exception: Syntax Error in template "index.tpl" on line 6 "{assign var='abc' value='def'}" unknown tag "NonExistentPlugin" in \libs\sysplugins\smarty_internal_templatecompilerbase.php on line 264


But it should be:
Quote:
Exception: Syntax Error in template "index.tpl" on line 3 "This is line 3 {NonExistentPlugin}<br>" unknown tag "NonExistentPlugin" in \libs\sysplugins\smarty_internal_templatecompilerbase.php on line 264




Additionaly, if I unlock the $Smarty->error_unassigned = true; and in template I use the non existent variable, the exception does not give me template nor line number where error occured.

Quote:
Exception: Undefined Smarty variable "MyNonExistentVariable" in \libs\sysplugins\smarty_internal_templatebase.php on line 228
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Nov 26, 2009 10:56 pm    Post subject: Reply with quote

A fix for the line number of unknown tags is in the SVN now.

The test for unassigned variables is done at render time to cover also dynamic variables created with tags like {assign} or pluging results which should have been assigned to a varibale. We don't have source line numbers available at render time.
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 -> Smarty 3 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