View previous topic :: View next topic |
Author |
Message |
danielgara Smarty Rookie
Joined: 13 Nov 2011 Posts: 6
|
Posted: Tue May 01, 2012 4:46 pm Post subject: Isset problem with POO |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue May 01, 2012 5:00 pm Post subject: |
|
|
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 |
|
danielgara Smarty Rookie
Joined: 13 Nov 2011 Posts: 6
|
Posted: Tue May 01, 2012 5:03 pm Post subject: |
|
|
I'm sorry, you are right, i was testing in php without the isset |
|
Back to top |
|
danielgara Smarty Rookie
Joined: 13 Nov 2011 Posts: 6
|
Posted: Tue May 01, 2012 5:13 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue May 01, 2012 5:27 pm Post subject: |
|
|
Smarty should automatically recompile the template after that change.
Or did you disable compile checks by setting $smarty->compile_check = false; ? |
|
Back to top |
|
danielgara Smarty Rookie
Joined: 13 Nov 2011 Posts: 6
|
Posted: Tue May 01, 2012 5:45 pm Post subject: |
|
|
I don't disable compile check.
For example I put
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:
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue May 01, 2012 6:29 pm Post subject: |
|
|
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 |
|
danielgara Smarty Rookie
Joined: 13 Nov 2011 Posts: 6
|
Posted: Tue May 01, 2012 6:38 pm Post subject: |
|
|
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:
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue May 01, 2012 6:49 pm Post subject: |
|
|
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 |
|
danielgara Smarty Rookie
Joined: 13 Nov 2011 Posts: 6
|
Posted: Thu Jun 21, 2012 4:17 am Post subject: |
|
|
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 |
|
|