White screens of death after removing a template file
I found the following error in my php error log:
PHP Fatal error: Call to a member function remove() on a non-object in /Users/XXXX/Localhost/XXXXXXX/core/cache/includes/elements/modplugin/11.include.cache.php on line 157
It caused a blank response on both frontpage and manager side.. Manually clearing the cache didn't work. I had to disable the plugin in phpMyAdmin and manually remove line 157 from the cache file: $element->remove();
After that I enabled the plugin again, cleared the cache and it seems to be working again now..
would something like that:
if ($element = $modx->getObject($element_type_name, array($name_field => $old_element_name))) {
$element->remove();
if ($debug)
{
$modx->log(modX::LOG_LEVEL_INFO, '[' . $classname . '] Removed ' . $element_type_name . ' ' . $old_element_name . ' from database');
}
}
fix that issue?
Hi hugopeek,
I've not seen this one before, could you post the steps to recreate the error?
Hmm, seemed to be a one-time glitch.. I think it was related to deleting an element that had been renamed before, but I didn't encounter this problem again.
I can confirm this issue, it's happened to me a couple times and I've fixed it by manually creating a chunk of the same name from phpmyadmin.
As far as I can tell, it happens when I rename a chunk/template from within modx, then change the static file name manually before EH has had a chance to do it (it's not EH's fault, it's because I've done things outside of the workflow), and it thinks it needs to delete a chunk that no longer exists.
I suppose just a check for if the chunk/template/snippet exists before attempting removal would fix the issue