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

10 days bug: Call to a member function on a non-object

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
ndorphin
Smarty Rookie


Joined: 24 Dec 2009
Posts: 15
Location: Berlin, Germany

PostPosted: Mon May 16, 2011 11:18 pm    Post subject: 10 days bug: Call to a member function on a non-object Reply with quote

Hi,

i use Smarty 3.0.7 with caching. All runs fine but after exactly a 10 days period (compared to my server logs) i get massive fatal errors "Call to a member function on a non-object". I've all things checked, the problem is only solvable by deleting all files in templates_c only (i don't delete cache dir). After deleting all is running fine until the next "crash". It must definitly be a bug, the 10 days are very strange (at least one times i remember that i've deleted the template_c dir between the 10 days after updating something). My caching time is definitly not set to 10 days (vary between 1 month or unlimited). The error occurs ever in smarty_internal_template.php (line 518) with a message like this:

PHP Fatal error: Call to a member function getProperty() on a non-object in
../smarty3/sysplugins/smarty_internal_template.php(518) : eval()'d code on line ...

I know that the my object function "getProperty()" will be called within an {nocache} block if the error occurs, i've tested it. So the bug must have something to do with {nocache}. I know what happens if you call a function on an non existing object within an {nocache} block, the error message is different then, not with "eval()'d"...

I hope that my problem is solved now by deleting templates_c one time per day with cron... The problem was on 3.0.6 too. I've updated to .7 in hope that solves the problem

Any ideas about that?

Thanks
ndorphin
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 17, 2011 2:22 pm    Post subject: Reply with quote

It looks like that the object variable which is calling the getProptery() method was not assigned.

The error occured in a case when Smarty wanted to write a new cache file.

Hard to tell the reasion without seeing your PHP script and template files.
Back to top
View user's profile Send private message
ndorphin
Smarty Rookie


Joined: 24 Dec 2009
Posts: 15
Location: Berlin, Germany

PostPosted: Thu May 19, 2011 2:42 am    Post subject: Reply with quote

Hi, as i said, i know whats happens when a (object) variable was not assigned. The described problem occurs after 10 days with *all* my cached files, wich running the days before fine. The error message with the eval'd message is different from the error message you'll get if you try to access an non setted object (i know this error). If i had a non setted object then only deleting the template_c dir would not help, but in my case only delteing it solves my problem..

My template files are so complex - i cant show this here.

I guess that my problem is a bug within the hashing (strings like SmartyNocache:4330926474dd1a3b9a6c2d7-93241468) inisde the template files. After deleting my template_c folder only the hashes within the files are changed. But i don't undertand the hashes & what they have to do...

Thanks for your help!
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu May 19, 2011 3:48 pm    Post subject: Reply with quote

The SmartyNocache hash value can't be the cause for this problem.
It's value is new each time a template compiles and is a protection against code injection.

It's strange that this error occours after 10 days if cache_liftetime is as large like a month, as the error occurs when a cache file is recreated. Have the source files for some reasion got a new modified date?

Do you assign the object variable in dependence of an isCached() condition?
Back to top
View user's profile Send private message
ndorphin
Smarty Rookie


Joined: 24 Dec 2009
Posts: 15
Location: Berlin, Germany

PostPosted: Thu May 19, 2011 9:47 pm    Post subject: Reply with quote

U.Tews wrote:
The SmartyNocache hash value can't be the cause for this problem.
It's value is new each time a template compiles and is a protection against code injection.

ok, this was only a suspicion of me

Quote:
Have the source files for some reason got a new modified date?

The source files (and its date) can be changed, i use setCompileCheck(false) to avoid that on small changes my hole cache (300.000 files) will be new generated and my server is down then. I set setCompileCheck() to true only if the page should be new generated.

Quote:
Do you assign the object variable in dependence of an isCached() condition?

The object variable is ever assigned, i need it's values for {nocache} blocks inside my cached files.

Here for clarification the different error messages:

error message if i forgot to set an object variable:
PHP Fatal error: Call to a member function getProperty() on a non-object in /../smarty/templates_c/cc26426e296ff59f37633c1fbf50cc60f0d2139a.file.xy.tpl.php on line 41

error message on my "10 days bug":
PHP Fatal error: Call to a member function getProperty() on a non-object in /../smarty3/sysplugins/smarty_internal_template.php(518) : eval()'d code on line 114

Thanks in advance!
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 -> Smarty 3 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