Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Fatal error: in ...smarty_internal_templatecompilerbase.php

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
halmai
Smarty n00b


Joined: 10 Mar 2016
Posts: 4

PostPosted: Thu Mar 10, 2016 12:07 pm    Post subject: Fatal error: in ...smarty_internal_templatecompilerbase.php Reply with quote

I am migrating an old project from PHP 5.X to 7.0.4 and Smarty from 2.6.27 to 3.1.29. After solving several smaller issues, I got a surprising error message

Quote:
Fatal error: in C:\...\smarty-3.1.29\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 8


The strange thing is that the 8th line of this file is the middle of a multi-line phpdoc comment. There is no code execution at all.

Why is this error message displayed and what does it mean?

------------------

After a painful investigation, it turned out that the line number of the error message is OK but the file name is not. The error was not in the 8th line of the mentioned php code. It was in the 8th line of my template instead.

The template file was an ISO-8859-2 encoded file with some international characters:

Code:
   BLAH
   { * re'szleteze's  * }
   BLA


(I wasn't able to enter accented e character (eacute in html) into this forum so I indicated it with an e and and apostrophe. In the original file it was the character that's ascii code is 0xe9.)

The word "reszletezes" in the 8th line of the template file contained the culprit characters in it. After changing the international characters to its English counterparts, the error disappeared.

Older smarty version (2.X) was running fine with international smarty comments. It's OK if the newer smarty doesn't like international characters but the misleading error message should be fixed, I think.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1520

PostPosted: Thu Mar 10, 2016 5:15 pm    Post subject: Reply with quote

http://www.joelonsoftware.com/articles/Unicode.html seriously…
Back to top
View user's profile Send private message
halmai
Smarty n00b


Joined: 10 Mar 2016
Posts: 4

PostPosted: Fri Mar 11, 2016 1:52 am    Post subject: Reply with quote

Thanks for the UTF-8 material but it doesn't help. The error message is still misleading so it should be fixed. Seriously. ;)
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Mar 11, 2016 4:15 am    Post subject: Reply with quote

Please see your private message
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1520

PostPosted: Sat Mar 12, 2016 12:44 am    Post subject: Reply with quote

halmai wrote:
Thanks for the UTF-8 material but it doesn't help. The error message is still misleading so it should be fixed. Seriously. Wink

Reencode your templates, and it should just work.
If it still doesn't work, then post again.
Back to top
View user's profile Send private message
halmai
Smarty n00b


Joined: 10 Mar 2016
Posts: 4

PostPosted: Sat Mar 12, 2016 12:54 am    Post subject: Reply with quote

What do you mean re-encode? Should I convert the ISO-8859-2 templates to UTF-8?

I don't think it is the desired solution because the whole project is not UTF-8. It would require re-encoding the whole database (~150 tables), all the templates (>500 files, >1MB), and modifying the php-code accordingly. (~200 files, >2MB).

Plus the external communication with other systems is also not UTF-8.

I really hope there is an easier solution.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1520

PostPosted: Sat Mar 12, 2016 3:32 am    Post subject: Reply with quote

1. You don't need to reencode database. If you are running sane DB server, and your tables are created with correct collation, it can do charset conversion at runtime. Just specify correct charset for connection.
2. Recoding templates is, again, easy.
Code:
find . -iname '*.tpl' -execdir wrapper.sh '{}' \;


There's no way around wrapping it that I know, because you need to supply the name twice. Wrapper could be something like
Code:
#!/bin/sh
_tmp="$( mktemp "./$1.XXXXXXX" )"
iconv -f ISO-8859-2 "$1" > "$_tmp" && mv "$_tmp" "$1"


PHP code will likely not need any modifications whatsoever. (Beyond correct database connection initialization and probably converting the sources themselves to UTF-8.)
Back to top
View user's profile Send private message
halmai
Smarty n00b


Joined: 10 Mar 2016
Posts: 4

PostPosted: Sat Mar 12, 2016 11:25 am    Post subject: Reply with quote

Maybe I will update the project in the future but, due to the many external connections, it is definitely more work than you assume. Thanks for the ideas, buy the way.

Anyway, this topic here is not about upgrading my project. This is about a misleading smarty error message. So, if the developers can reproduce the error then it should be fixed, I think.

Uwe wrote he was unable to reproduce it by himself so I sent him the sample files, the minimised ones. I hope he can see the error message. If anyone else needs it then drop me an email and I will send it.

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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