I am using the 4.4.0 version and I notice that after scheduling an hide or post, if you decide to remove them later the entry isn't removed from the DB table. Which means after scheduling you can't remove it anymore.

I made a change in the write hook and added some lines, I don't know how to make a patch otherwise I'd provide one.
If anyone needs the same code here it is:

** Just replace this: **

function scheduler_write($node, $op, $arg) {

  if (user_access("administer nodes") && ($node->scheduler_post || $node->scheduler_hide)) {

    if ($node->scheduler_post) {
      $conds["timestamp_posted"] = scheduler_nodetime($node, "post");
    }
    else {
      $conds["timestamp_posted"] = 0;
    }
    if ($node->scheduler_hide) {
      $conds["timestamp_hidden"] = scheduler_nodetime($node, "hide");
    }
    else {
      $conds["timestamp_hidden"] = 0;
    }

    if ($op !== "insert") {
      // Determine whether we must UPDATE or INSERT, then do it
      $result = db_query("SELECT * FROM {scheduler} WHERE nid = %d", $node->nid);
      if (db_num_rows($result)) {
        foreach ($conds as $key => $value) {
          $update_conds[] = "$key=$value";
        }
        db_query("UPDATE {scheduler} SET %s WHERE nid = %d", implode(", ", $update_conds), $node->nid);
      }
      else {
        scheduler_insert($node, $conds);
      }
    }
    else {
      scheduler_insert($node, $conds);
    }
  }
}

** With this: **

function scheduler_write($node, $op, $arg) {

  if (user_access("administer nodes") && ($node->scheduler_post || $node->scheduler_hide)) {

    if ($node->scheduler_post) {
      $conds["timestamp_posted"] = scheduler_nodetime($node, "post");
    }
    else {
      $conds["timestamp_posted"] = 0;
    }
    if ($node->scheduler_hide) {
      $conds["timestamp_hidden"] = scheduler_nodetime($node, "hide");
    }
    else {
      $conds["timestamp_hidden"] = 0;
    }

    if ($op !== "insert") {
      // Determine whether we must UPDATE or INSERT, then do it
      $result = db_query("SELECT * FROM {scheduler} WHERE nid = %d", $node->nid);
      if (db_num_rows($result)) {
        foreach ($conds as $key => $value) {
          $update_conds[] = "$key=$value";
        }
        db_query("UPDATE {scheduler} SET %s WHERE nid = %d", implode(", ", $update_conds), $node->nid);
      }
      else {
        scheduler_insert($node, $conds);
      }
    }
    else {
      scheduler_insert($node, $conds);
    }
  }
  else {
      // In case there used to be an entry but now it's disabled remove it from the DB
      $result = db_query("SELECT * FROM {scheduler} WHERE nid = %d", $node->nid);
      if (db_num_rows($result)) {
        db_query("DELETE FROM {scheduler} WHERE nid = %d", $node->nid);
      }
  }
}

I do think this should be implemented into the module, but maybe it's already fixed in the 4.5.0 version.

Comments

moshe weitzman’s picture

not sure i understand the problem. but this surely isn't a good fix. perhapsn we need a listener on nodeapi('delete')

jgoerzen@forest.complete.org’s picture

I saw this too, in 4.5.0.

Let me try to explain.

Step 1: I go and create a story. I schedule it to post tomorrow.

Step 2: I decide that I would like it to post immediately. I go to edit that node. I mark it
Published, and uncheck the "schedule" checkbox.

Step 3: I click Submit. The node gets posted, but the "schedule" checkbox gets re-checked.

The problem would be worse if step 2 was "I decide not to post this until some indefinite time in the future".

Gábor Hojtsy’s picture

Just fixed this problem with a simpler patch in 4.4, 4.5 and HEAD. HEAD also got a 'delete' nodeapi implementation, so schedules will actually be deleted, when nodes are deleted, among other new stuff.

Anonymous’s picture