CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#7259] Fatal error: Call to a member function getContent()

avatar
Created By: Prue Rowland (psy)
Date Submitted: Sun Nov 27 17:41:28 -0500 2011

Assigned To:
Version: 1.10.2
CMSMS Version: 1.10.2
Severity: Critical
Resolution: Fixed
State: Closed
Summary:
Fatal error: Call to a member function getContent()
Detailed Description:
Site will crash in a very ugly manner when the following series of events occur:

- there are multiple requests in various stages of completion
- one of the requests triggers the ClearCache task
- one of the other requests contains a Smarty object that requires a
HierarchyManager object

Scenario:

Request A begins a nanosecond before the ClearCache task is due to be called. 
It looks in the tmp directories and finds the compiled templates.  It 'believes'
from that point forward it should work from the cached files.

Request B arrives a nanosecond later and meets the time test for the ClearCache
state task.  Before proceeding to generate its page, it recursively deletes all
the files from the cache.

Request A contains a Smarty object that requires a HierarchyManager object, eg
{cms_selflink dir=start} or {SEOTools}.  It goes to the cache directory to
retrieve the contentcache.php file which contains a serialized version of the
hierarchy tree.  Meanwhile Request B has deleted this file.  As a result, the
cms_content_cache method get_content($identifier) returns null and the
HierarchyManager object fails to instantiate.

Request A then tries to process the HM function, eg getContent() but cannot and
the site crashes with the "Fatal error: Call to a member function getContent()
on a non-object".

Manually clearing the cache after the error has occurred will temporarily solve
the problem but will not guarantee that the situation will not arise again.  The
busier the site, the more likely the crash will occur.

Error has been seen in CMSMS versions 1.9+, ie when the ClearCache task was
introduced.



History

Comments
avatar
Date: 2012-04-14 15:45
Posted By: Ronny Krijt (ronnyk)

ClearCache shouldnt act on frontend request, and backend cache-clearing only
acts automatically per x-days old cache...
      
avatar
Date: 2012-04-16 07:58
Posted By: Prue Rowland (psy)

Firstly, thank you Ronny for responding to the bug report.

My concept may be wrong however I truly believe there is a major flaw in the
core logic.  I tried to do what Calguy suggested when you have a problem, ie:

- think about it for an hour (read 10+)
- trawl through the code
- try to recreate the circumstance
- report everthing in detail

If I were the only person experiencing the problem then I'd say it was something
I'd done, BUT I'm not.

In the site that has given me the most grief (and the crash happens now almost
daily).  Clearing the frontend cache temporarily solves the problem.  I truly
believe there is a major flaw in the ClearCache/Hierarchy Manager logic.  Please
help solve it.

psy



      
avatar
Date: 2012-04-16 08:06
Posted By: Prue Rowland (psy)

Forgot to mention, the frontend clear cache (either manual or automatic) deletes
the contentcache.php file that contains the page hierarchy info, hence
MenuManager crashes with the 'non object' error.
      
avatar
Date: 2012-05-18 06:25
Posted By: Alex Dittrich (faglork)

Just want to confirm that. I just had the problem as described above. Manually
clearing the cache helped - many thanks for posting a temporary solution.

This *needs* to get resolved, as it apparently occurs on big sites with many
visitors - just where the damage is very high.

Cheers,
Alex
      
avatar
Date: 2012-05-18 07:12
Posted By: Grant O'Neill (gocreative)

It can occur on sites of any size -- I have had some sites that had not even
launched yet and was having this issue, with only two different users looking at
it (and usually not simultaneously).

I also wanted to confirm the 'non object' MenuManager error as reported by
'psy'. This happens to me every time I clear the cache, which is obviously not
ideal.
      
avatar
Date: 2012-05-18 07:15
Posted By: Rolf (rolf1)

Check your website for {redirect_page page="foo"}, where 'foo' isn't an existing
page alias

grtz. Rolf

      
avatar
Date: 2012-05-18 07:43
Posted By: Prue Rowland (psy)

Thanks for the suggestion Rolf, however the site causing me the most pain with
this error has no {redirect_page page="foo"} type tags.  It's a reasonably busy
site that uses Hierarchy Manager objects ie MenuManager, which rely on
contentcache.php which in turn gets deleted mid-action.  I have tried every
possible thing to turn off the automatic cache clearing and anything else I can
think of.

Cheers also Alex and Grant for confirming I'm not the only one experiencing this
problem.





      
avatar
Date: 2012-05-18 07:56
Posted By: Rolf (rolf1)

But is the exact error message you get?
When having a false redirect I get:
Fatal error: Call to a member function GetContent() on a non-object in
/public/sites/www.buispost.eu/lib/misc.functions.php on line 139
      
avatar
Date: 2012-06-05 20:42
Posted By: Grant O'Neill (gocreative)

I had this happen today. The error was:

Fatal error: Call to a member function getContent() on a non-object in
/home/9-web/9b/d2/xxxxxx.com.au/public/www/plugins/function.cms_selflink.php on
line 283
      
avatar
Date: 2012-08-13 11:26
Posted By: Jon Sykes (jonsykes)

Just encountered this problem with same error as gocreative. Also within the CMS
admin I see no pages listed.

Issue resolved by manually clearing the cache.

This site was using CMS 1.9.4.2
      
Updates

Updated: 2012-09-07 15:13
resolution_id: 9 => 7
state: Open => Closed

Updated: 2012-04-14 15:45
resolution_id: => 9