Cron fails when Drush starts and calls node_load ()

I have a Drupal 6 site and I have a custom module that does some maintenance on specific nodes when cron runs.

My code is very simple:

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 problem is that when I run cron with drush core-cron it fails and says "drush command abnormally terminated due to fatal error"

Using some basic debugging skills, I tracked down the issue with calling node_load. Is there a reason why calling node_load in cron this way is causing drush core-cron to crash?

-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 a cron job from the web interface works fine without error. The problem seems to be related to drush.

I checked the watchdog, and whenever I try to run this from drush, Watchdog shows a new message under the cron header that says "Cron run timed out and was aborted." The weird thing is that I get the error almost immediately after hitting the CLI and in my current implementation, I'm just trying to debug node_load so that my maintenance tasks have been commented out. I'm just trying to dump the title of the node first in the list to the screen and then return true, so it should only be looping.

The reason this problem occurs is because the only way we could run cron from crond is by using drush. But if drush cannot execute this command, then I'm stumped.

Even using Drush 5 doesn't solve the problem.

+3


source to share


1 answer


Do you have PHP filter module enabled? I bet someone put bad code in one of your nodes. This is one of the many reasons why a php module should never be used ...



0


source







All Articles