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

Isset problem with POO

 
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
danielgara
Smarty Rookie


Joined: 13 Nov 2011
Posts: 6

PostPosted: Tue May 01, 2012 4:46 pm    Post subject: Isset problem with POO Reply with quote

Hi,

I'm using POO, I create a class called 'banner' in php, this class have a get method that return an attribute.

When I assign a object called 'banner' to template, and I put

Code:
{if isset($banner->get('title'))}...{/if}


I get:

Code:
Fatal error: Can't use method return value in write context in ...


I'm using the 3.1.8 smarty version

Thank you so much
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue May 01, 2012 5:00 pm    Post subject: Reply with quote

This is no bug. You can't use isset() on an object method result. This is an PHP error not Smarty's

Use
Code:
{if $banner->get('title')}...{/if}
Back to top
View user's profile Send private message
danielgara
Smarty Rookie


Joined: 13 Nov 2011
Posts: 6

PostPosted: Tue May 01, 2012 5:03 pm    Post subject: Reply with quote

I'm sorry, you are right, i was testing in php without the isset
Back to top
View user's profile Send private message
danielgara
Smarty Rookie


Joined: 13 Nov 2011
Posts: 6

PostPosted: Tue May 01, 2012 5:13 pm    Post subject: Reply with quote

But I have another cuestion, after I deleted that line

Code:
{if isset($banner->get('title'))}...{/if}


The Fatal error continue appearing.

Code:
Fatal error: Can't use method return value in write context in ...


I must to clean by myself the templates_c for show the website normally.
It doesn't happen with the others wrongs, I don't need clean by myselft the templates_c
is it normal?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue May 01, 2012 5:27 pm    Post subject: Reply with quote

Smarty should automatically recompile the template after that change.

Or did you disable compile checks by setting $smarty->compile_check = false; ?
Back to top
View user's profile Send private message
danielgara
Smarty Rookie


Joined: 13 Nov 2011
Posts: 6

PostPosted: Tue May 01, 2012 5:45 pm    Post subject: Reply with quote

I don't disable compile check.

For example I put
Code:
{iff $var}

I obtain:
Code:
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "C:/wamp/www/supergas/templates/t_dark\index.tpl" on line 10 "{iff $var}{/if}" unknown tag "iff"' in C:\wamp\www\supergas\modules\m_smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 627

Later I delete that line:
Code:
{iff $var}

I obtain: the normal website

BUT if I repeat this proccess with the last wrong:
I put:
Code:
{if isset($banner->get('title'))}...{/if}

I obtain:
Code:
Fatal error: Can't use method return value in write context in C:\wamp\www\supergas\templates_c\1866c0d6016eb620e97757ad2b556aa66e0869eb.file.index.tpl.php on line 62

Later I delete that line:
Code:
{if isset($banner->get('title'))}...{/if}

I obtain:
Code:
Fatal error: Can't use method return value in write context in C:\wamp\www\supergas\templates_c\1866c0d6016eb620e97757ad2b556aa66e0869eb.file.index.tpl.php on line 62


It is so strange, then I need clean by myself the templates_c
This only happens with this specific error
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue May 01, 2012 6:29 pm    Post subject: Reply with quote

Arg

This specific case creates a fatal runtime error which exits PHP before it can recompile the modified template. This is a deadlock unless you delete the wrong compiled file.
Back to top
View user's profile Send private message
danielgara
Smarty Rookie


Joined: 13 Nov 2011
Posts: 6

PostPosted: Tue May 01, 2012 6:38 pm    Post subject: Reply with quote

Additional information:

I have others projects with smarty 3.0.6

I put that line in these projects, later delete that line, and the website load normally

It seems that the problem could be in the smarty version

Other line that created problems in smarty is:
Code:
{$whatever::g()}


I obtain:
Code:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';' in C:\wamp\www\supergas\templates_c\1866c0d6016eb620e97757ad2b556aa66e0869eb.file.index.tpl.php on line 62


After delete that line:
- In smarty 3.0.6 I don't need to clean by myself the templates_c and the website loads right
- In smarty 3.1.8 I must clean by myself the templates_c

Thank you so much U.Tews
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue May 01, 2012 6:49 pm    Post subject: Reply with quote

Yes, there is a diffrence in the handling of compiled files in 3.0 and 3.1.

I must check how this can be resolved.
Back to top
View user's profile Send private message
danielgara
Smarty Rookie


Joined: 13 Nov 2011
Posts: 6

PostPosted: Thu Jun 21, 2012 4:17 am    Post subject: Reply with quote

hi U. Tews

do you have news about this bug?
I downloaded the last version 3.1.9 and 3.1.10 but I obtained the same problem.

Thank you so much for your collaboration.
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