Closed (fixed)
Project:
Node Moderation
Version:
master
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Oct 2004 at 22:10 UTC
Updated:
20 Oct 2004 at 16:49 UTC
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);
}
| Comment | File | Size | Author |
|---|---|---|---|
| patch.patch | 1.38 KB | ixis.dylan |
Comments
Comment #1
ixis.dylan commentedNot sure what happened with the patch, because I've somehow diffed it against a different version of the module. Still works, though...
Comment #2
moshe weitzman commentedcommitted a quick fix to HEAD. thanks.
Comment #3
ixis.dylan commentedThanks!