1 node.module node_cron()

Implements hook_cron().

File

core/modules/node/node.module, line 116
The core module that allows content to be submitted to the site.

Code

function node_cron() {
  db_delete('history')
    ->condition('timestamp', NODE_NEW_LIMIT, '<')
    ->execute();

  $scheduled_nodes = db_select('node', 'n')
    ->fields('n', array('nid'))
    ->condition('status', 0)
    ->condition('scheduled', 0, '!=')
    ->condition('scheduled', REQUEST_TIME, '<=')
    ->execute();
  foreach ($scheduled_nodes as $n) {
    if ($node = node_load($n->nid)) {
      $node->status = 1;
      $node->created = $node->scheduled;
      $node->scheduled = 0;
      $node->save();
    }
  }
}