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

Upgrading from Smarty 2 to Smarty 3
Goto page 1, 2  Next
 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Thu Jun 10, 2010 6:37 pm    Post subject: Upgrading from Smarty 2 to Smarty 3 Reply with quote

Smarty 3 is an entire remake, and it differs from Smarty 2. But the template rendering, and plugins work as in earlier version. However, you may need to consider to upgrade to Smarty 3.

The developers have a quick documentation for this process at:
http://dev.smarty.net/wiki/index.php/Upgrading_from_Smarty_2

To upgrade, please be sure that your server supports PHP 5.
Otherwise, it wont work correctly. Also, check if you have used {php} tags in your older files.

Manual written for 2.6.14 still works for many references.
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jun 10, 2010 6:46 pm    Post subject: Reply with quote

There are not newlines generated by {if} tags, can you provide an example?
Back to top
View user's profile Send private message Visit poster's website
kosemuckel
Smarty Rookie


Joined: 13 May 2007
Posts: 15

PostPosted: Fri Dec 31, 2010 10:46 am    Post subject: Reply with quote

Quote:
The developers have a quick documentation for this process at:
http://dev.smarty.net/wiki/index.php/Upgrading_from_Smarty_2


would be nice to have this public and not restricted Sad
Back to top
View user's profile Send private message
idontknow
Smarty Rookie


Joined: 22 Jan 2011
Posts: 6
Location: Germany

PostPosted: Sat Jan 22, 2011 2:30 am    Post subject: Reply with quote

kosemuckel wrote:
Quote:
The developers have a quick documentation for this process at:
http://dev.smarty.net/wiki/index.php/Upgrading_from_Smarty_2


would be nice to have this public and not restricted Sad


this is totally true!!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Jan 22, 2011 3:42 am    Post subject: Reply with quote

There are upgrade notes with the Smarty 3 distro.
Back to top
View user's profile Send private message Visit poster's website
Chrissio
Smarty Rookie


Joined: 07 Oct 2014
Posts: 10

PostPosted: Tue Jan 06, 2015 4:21 pm    Post subject: Reply with quote

mohrt wrote:
There are upgrade notes with the Smarty 3 distro.


... but - i don't understand it! The only i see in first tests is:

Quote:
Fatal error: Call to a member function createTemplate() on null in C:\xampp\htdocs\Smarty3\libs\sysplugins\smarty_internal_templatebase.php on line 49


With this error message (without any further info) no one can do something!

Upgrade description from ver. 2 to ver. 3 is very very bad!
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Jan 06, 2015 10:57 pm    Post subject: Reply with quote

Chrissio wrote:
mohrt wrote:
There are upgrade notes with the Smarty 3 distro.


... but - i don't understand it! The only i see in first tests is:

Quote:
Fatal error: Call to a member function createTemplate() on null in C:\xampp\htdocs\Smarty3\libs\sysplugins\smarty_internal_templatebase.php on line 49


With this error message (without any further info) no one can do something!

Upgrade description from ver. 2 to ver. 3 is very very bad!

Actually, this line indicates that you are doing something you should never attempt to do.
Back to top
View user's profile Send private message
Chrissio
Smarty Rookie


Joined: 07 Oct 2014
Posts: 10

PostPosted: Tue Jan 06, 2015 11:19 pm    Post subject: Reply with quote

AnrDaemon wrote:

Actually, this line indicates that you are doing something you should never attempt to do.


Hello,

but the script runs with Smarty2...

After 4 hours searching with Smarty3 I found the Error:

It was to change 1 line from
Code:
 $tpl = some_function_somewhere();

to
Code:
$tpl = new Smarty;


The problem is, most Smarty error Messages are the same like

Quote:
Fatal error: Call to a member function createTemplate() on null in C:\xampp\htdocs\Smarty3\libs\sysplugins\smarty_internal_templatebase.php on line 49


But to fix the error you need to search in many other files, because the Error isn't in smarty_internal_templatebase.php on line 49 - it is somewhere in another File outside of smarty folder, and smarty debug dosn't run in this case.

Thats very unfortunely! And the same like an error Message from apache webserver because an error in postfix... Shocked
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Jan 07, 2015 12:18 am    Post subject: Reply with quote

Is that line in any of the Smarty code, or is that in your application code?
Back to top
View user's profile Send private message
Chrissio
Smarty Rookie


Joined: 07 Oct 2014
Posts: 10

PostPosted: Wed Jan 07, 2015 10:24 am    Post subject: Reply with quote

AnrDaemon wrote:
Is that line in any of the Smarty code, or is that in your application code?


I wrote: "it is somewhere in another File outside of smarty folder" and means "has nothing to do with a file in smarty engine".

It is a line in application code - but php says "you have an error in smarty engine".

An this is the problem because php tells an error in a place fare away from the really error.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Jan 07, 2015 11:25 am    Post subject: Reply with quote

Nowhere in your post I see that there's an "error in Smarty engine".
Error in your application code? That one I see.
Back to top
View user's profile Send private message
Chrissio
Smarty Rookie


Joined: 07 Oct 2014
Posts: 10

PostPosted: Wed Jan 07, 2015 9:57 pm    Post subject: Reply with quote

AnrDaemon wrote:
Nowhere in your post I see that there's an "error in Smarty engine".
Error in your application code? That one I see.


Sorry, i want to change from smarty 2 to smarty 3!

The script runs correctly in smarty 2 /php5.6 with deprecated messages - but it produces error messages after change to smarty 3. Exactly the big problem are the error messages - all Errors are shown as Errors in "smarty_internal_templatebase.php"!

Exactly that is the problem because the reason of the error is NOT THE SMARTY ENGINE...

But - i want to end writing with you because your post give no hints for to get correct error messages because normally an error message should be like "Error in filexy.php" if the error ist in filexy.php. In this case the error was in filexy, but php says the error ist in smarty. EOM
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Jan 07, 2015 10:17 pm    Post subject: Reply with quote

If there's no Smarty class instance available, when internal plugins run, that could only mean, that you're calling internal template functions directly, which you SHOULD NEVER EVER DO.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sat Jan 10, 2015 4:53 pm    Post subject: Reply with quote

Where did you need to change a line to

Code:
$tpl = new Smarty;


Show a piece of code around it.

$tpl is an internal variable used in Smarty3.
Did you extend the Smarty class and overload some of the Smarty methods?
If yes that code must be reviewed carefully because of internal changes.


One major change is in plugins. The second parameter is no longer the Smarty but the template object $template.

Code:
void smarty_function_name($params,   
    Smarty_Internal_Template $template);   


Normally an access to Smarty properties and methods should be automatically remapped to the Smarty object. But you have direct access to the Smarty object by using
Code:
$template->smarty
Back to top
View user's profile Send private message
Chrissio
Smarty Rookie


Joined: 07 Oct 2014
Posts: 10

PostPosted: Mon Jan 19, 2015 11:19 am    Post subject: Reply with quote

U.Tews wrote:
Where did you need to change a line to

Code:
$tpl = new Smarty;


Show a piece of code around it.

$tpl is an internal variable used in Smarty3.


Hello Uwe,

a very useful hint. Now i can recognize the reason of some other errror messages.

$tpl was used in the script with Smarty2 - i have to change it in the script...

Thank you.
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 -> Tips and Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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