View previous topic :: View next topic |
Author |
Message |
Mike87 Smarty n00b
Joined: 04 Feb 2015 Posts: 3
|
Posted: Thu Feb 05, 2015 12:04 am Post subject: Illegal String Offset Error |
|
|
Hello,
I am new with smarty. I have it installed on my webserver and now I receive constantly the following error in my php log file:
PHP Warning: Illegal string offset 'id' in .../smarty_internal_templatebase.php(157) : eval()'d code on line 90
I checked the file mentioned and searched for line 90 (second line of the below):
// check URL debugging control
if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
I also checked line 157 (fourth line of the below):
if (!$_template->compiled->exists || ($_template->smarty->force_compile && !$_template->compiled->isCompiled)) {
$_template->compileTemplateSource();
$code = file_get_contents($_template->compiled->filepath);
eval("?>" . $code);
unset($code);
$_template->compiled->loaded = true;
$_template->compiled->isCompiled = true;
}
I am not a professional programmer but it would be very nice if anyone could give me a hint where to search for that mistake. I am not asking for a complete solution but at the moment I have no clue at all. It might be helpful if someone could just explain the error... |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Feb 05, 2015 6:50 pm Post subject: |
|
|
The error must be in your template source.
Line 90 is in the compiled template, however we can't see corresponding PHP source.
Do you use in your template an index or variable 'id' ? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Feb 05, 2015 7:24 pm Post subject: |
|
|
Caching template output with unset {nocache} variables?
P.S.
@U.Tews: What is the chances for Smarty to work without eval()? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Feb 05, 2015 8:13 pm Post subject: |
|
|
I don't think it's an unassigned variable.
Upcomming 3.1.22 will work without eval |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Feb 05, 2015 8:58 pm Post subject: |
|
|
Seriously? O.o
Cause I was considering to put eval() into disabled functions on some of the servers I manage, since their owners absolutely unable to hold their own hands straight, and I had to ditch rShell and the kind not once.
Blocking eval() and some other functions makes it at least considerable harder to break into running PHP process, as well as break out of it. |
|
Back to top |
|
Mike87 Smarty n00b
Joined: 04 Feb 2015 Posts: 3
|
Posted: Thu Feb 05, 2015 9:33 pm Post subject: |
|
|
Thank you for your replies. I give my best:
Line 90 of the compiled template tpl-file:
<?php if ($_smarty_tpl->tpl_vars['ooocat']->value['id']==$_smarty_tpl->tpl_vars['parents']->value['id_category']) {?>
<?php $_smarty_tpl->tpl_vars['is_in_subcategories'] = new Smarty_variable(1, null, 0);?>
<?php }?>
I am using smarty as part of the newly installed prestashop. Do you think it is more an error in the code of prestashop rather than smarty? That would bring me already one step further. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Feb 05, 2015 10:14 pm Post subject: |
|
|
It looks like that template variable $ooocat is not an array which has an element with index 'id', but is a string.
It's not a Smarty error. |
|
Back to top |
|
Mike87 Smarty n00b
Joined: 04 Feb 2015 Posts: 3
|
Posted: Fri Feb 06, 2015 10:26 am Post subject: |
|
|
Ok I will try to work with it further. Thank you for your help so far |
|
Back to top |
|
|