I have a 'ticket' content type which uses the 'comment' content type as comments, which are set to read/write by default in the 'ticket' content type and are not changed in specific 'ticket' nodes.

This works great, except I have a computed field in 'ticket' which totals fields from associated 'comment' nodes. Because of this, I have to use rules (I've also tried manually, so this doesn't have to do with the rules module) to trigger manual PHP code whenever a 'comment' node is added or updated. I've tried a few different permutations:

$res = db_query("SELECT n.nid FROM {node} n WHERE n.type = 'ticket'");
while ($n = db_fetch_object($res)){
   $node = node_load($n->nid);
   $n = node_save($node);
}
$query = 'SELECT nid FROM content_type_ticket';
$profilenidarray = array();
$profilenidarray = db_query($query);
while ($nodeID = db_fetch_array($profilenidarray)){
set_time_limit(5);
$PNID = node_load($nodeID["nid"]);
node_save($PNID);
}

I've pulled these snippets from others, as I'm not a coder, but I can intuitively understand their function and I don't see any major problems.

When this code is run, either as a rule or manually, the computed fields in the 'ticket' content type update perfectly. However, comments on the re-saved nodes are changed from 'read/write' to 'disabled'. When I manually set this to 'read/write' again, everything works fine until the php code is run, at which point the problem reoccurs.

Comments

crea’s picture

Category: support » bug
Status: Active » Closed (duplicate)