Fixing MODX Revolution Errors on php v.5.4.13
While deploying MODX Revolution on a server with php v.5.4.13 I ran into a broken admin panel and search.
In the apache log I found the following error:
PHP Fatal error: Call to a member function setCacheable() on a non-object in core/cache/includes/elements/modsnippet/31.include.cache.php on line 31
Searching the internets didn’t get me anywhere. Everyone suggests reinstalling ModX, clearing the core/cache folder, and so on.
Needless to say, none of that advice helps.
To fix it, you need to wrap $tpl->setCacheable(false); in a conditional, like this:
if (is_object($tpl)) {
$tpl->setCacheable(false);
}
The same approach fixes the following nasty one:
PHP Fatal error: Call to a member function get() on a non-object in core/model/modx/modmanagerresponse.class.php on line 41
if (is_object($action)){
$action = $action->get('id');
}