In nmoderation_set_status(), node_load() and node_save() are being called unnecessarily (I think). This updates the timestamp on the node whenever a user votes on it, which flags it as "new" in various parts of Drupal.

The node is only modified if there are enough votes in either direction to promote or unpublish it. I've moved the calls inside the if() as a quick fix. Here's a copy of the new function, and I've attached a patch to this issue.

Thanks for the module!

// will either promote or unpublish or do nothing, depending on the curent score for this node
function nmoderation_set_status($gid, $realm = 'node_nid') {
  $sql = "SELECT SUM(value)AS score FROM {nmoderation_uservotes} WHERE gid = $gid AND realm = '$realm'";
  $result = db_query($sql);
  $row = db_fetch_object($result);
  $node = node_load(array('nid' => $gid));
  // have to load terms in order that they don't get lost upon saving the node.
  $node->taxonomy = array_keys(taxonomy_node_get_terms($gid));
  if ($row->score > variable_get('nmoderation_threshold_promote', 4)) {
    $node->promote = 1;
  }
  elseif ($row->score < variable_get('nmoderation_threshold_unpublish', 4)) {
    $node->status = 0;
  }
  node_save($node);
}
CommentFileSizeAuthor
patch.patch1.38 KBixis.dylan

Comments

ixis.dylan’s picture

Not sure what happened with the patch, because I've somehow diffed it against a different version of the module. Still works, though...

moshe weitzman’s picture

committed a quick fix to HEAD. thanks.

ixis.dylan’s picture

Thanks!