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.