I have a Drupal 6 site and I have a custom module that performs some maintenance operations on certain nodes when cron is run.
My code is very simply:
function mymodule_cron() {
// get all the nodes that need maintenance
$result = db_query("SELECT * FROM {mymodule_nodes}");
while ($row = db_fetch_object($result)) {
// load the node
$node = node_load($row->nid); // Causes Drush Error
// Perform Maintenance Tasks
}
}
The trouble is, when I run cron using drush core-cron, it fails and says: "drush command terminated abnormally due to an unrecoverable error"
Using some basic debugging skills, I traced the problem to the node_load call. Is there a reason why calling node_load in cron in this way causes drush core-cron to fail?
-sh-4.1$ drush status
Drupal version : 6.17
Database : Connected
Drupal bootstrap : Successful
Drush version : 4.5
Drush configuration :
Drush alias files :
-sh-4.1$ php -v
PHP 5.3.6 (cli) (built: Mar 17 2011 20:56:13)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
-sh-4.1$ httpd -v
Server version: Apache/2.2.17 (Unix)
Server built: Oct 27 2010 10:04:21
Running the Cron Job from the web interface works fine without error. The problem seems to be drush related.
I checked watchdog and whenever I try to run this from drush, Watchdog shows a new message under the cron Type saying "Cron run exceeded the time limit ans was aborted". Strange thing is, I get the error almost immediately after hitting enter from the CLI and in my current implementation, I'm simply trying to debug the node_load so I've got my maintenance tasks commented out. I'm just trying to dump the node title of the first one in the list to the screen and then returning true, so it should only be looping once.
The reason why this is such a problem is because the only way we've been able to get cron to run from crond is by using drush. But if drush can't execute this command, then I'm at an impasse.
Even using Drush 5 doesn't resolve the problem.