Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to update a node in a hook_cron() function. I am using Drupal 6.

Here is my code:

function offers_cron() {
  $query= db_query("SELECT * FROM {node} WHERE type = 'product'");
  while($allnodes = db_fetch_object($query)){

    $node = new stdClass();
    $node->nid = $node_id;  

    $node->type = 'product';
    $node->language = 'en';
    $node->status = 1; 
    $node->created = time();
    $node->changed = $node->created;
    $node->promote = 0; 
    $node->sticky = 0;  
    $node->format = 2;  

    if ($node = node_submit($node)) {
      drupal_set_message(t("Node ".$node->title." added correctly"));
    } else {
      drupal_set_message(t("Node ".$node->title." added incorrectly"), "error");

Now it shows it has updated all nodes. Here is screen shot for this :

enter image description here

Now when I click any node the update does not show.

Please take a look:

enter image description here

Does anybody have any ideas about this?

I have even tried clearing the cache.


share|improve this question
up vote 0 down vote accepted

I got the solution: If the node doesn't change, don't create a new revision.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.