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

Illegal String Offset Error

 
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 -> General
View previous topic :: View next topic  
Author Message
Mike87
Smarty n00b


Joined: 04 Feb 2015
Posts: 3

PostPosted: Thu Feb 05, 2015 12:04 am    Post subject: Illegal String Offset Error Reply with quote

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... Smile
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Feb 05, 2015 6:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 05, 2015 7:24 pm    Post subject: Reply with quote

Caching template output with unset {nocache} variables?

P.S.
@U.Tews: What is the chances for Smarty to work without eval()?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Feb 05, 2015 8:13 pm    Post subject: Reply with quote

I don't think it's an unassigned variable.

Upcomming 3.1.22 will work without eval
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 05, 2015 8:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mike87
Smarty n00b


Joined: 04 Feb 2015
Posts: 3

PostPosted: Thu Feb 05, 2015 9:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Feb 05, 2015 10:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mike87
Smarty n00b


Joined: 04 Feb 2015
Posts: 3

PostPosted: Fri Feb 06, 2015 10:26 am    Post subject: Reply with quote

Ok I will try to work with it further. Thank you for your help so far Smile
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 -> General 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