Magento 1: Cron fatal error in app/code/core/Mage/Cron/Model/Observer.php
-
30-09-2020 - |
Domanda
One of my client's CRON daemon recently started sending those errors:
PHP Fatal error: Call to a member function addFieldToFilter() on a non-object in /app/code/core/Mage/Cron/Model/Observer.php on line 105
Running Magento 1.8.1.0
This corresponds to the following lines:
$this->_pendingSchedules = Mage::getModel('cron/schedule')->getCollection()
->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING)
->load();
I've already ensured that the Mage_Cron_Model_Resource_Schedule_Collection
class exists and the file is at the right location.
I've also checked the cron_schedule
table and cron is running fine, most of the scheduled job are in the success
status and there's a few pending
jobs as well.
I'm not quite sure where I should start debugging. Any clue where I should start looking to narrow down the issue ?
Soluzione
The code in question is:
$this->_pendingSchedules = Mage::getModel('cron/schedule')->getCollection()
->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING)
->load();
Based on that, your problem is that getCollection()
is not returning the object Magento expects. Is anything overriding cron/schedule
, or its collection cron/resource_schedule_collection
?
I would suggest adding logging in there to determine the exact type (get_class($var)
) of Mage::getModel('cron/schedule')
and Mage::getModel('cron/schedule')->getCollection()
in that context. That should give you an idea of where to proceed. Let it run, see what comes out.
It's hard to speculate about the root cause without more info. I suspect a problem with configuration (module XML), either a file being broken, or some module overriding or replacing some XML it shouldn't.