View previous topic :: View next topic |
Author |
Message |
halmai Smarty n00b
Joined: 10 Mar 2016 Posts: 4
|
Posted: Thu Mar 10, 2016 12:07 pm Post subject: Fatal error: in ...smarty_internal_templatecompilerbase.php |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
halmai Smarty n00b
Joined: 10 Mar 2016 Posts: 4
|
Posted: Fri Mar 11, 2016 1:52 am Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Mar 11, 2016 4:15 am Post subject: |
|
|
Please see your private message |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Mar 12, 2016 12:44 am Post subject: |
|
|
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. |
Reencode your templates, and it should just work.
If it still doesn't work, then post again. |
|
Back to top |
|
halmai Smarty n00b
Joined: 10 Mar 2016 Posts: 4
|
Posted: Sat Mar 12, 2016 12:54 am Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Mar 12, 2016 3:32 am Post subject: |
|
|
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 |
|
halmai Smarty n00b
Joined: 10 Mar 2016 Posts: 4
|
Posted: Sat Mar 12, 2016 11:25 am Post subject: |
|
|
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 |
|
|