I have a triggered action which works to replace one vocabulary term with another (in the same vocabulary). It works very well. However, I encounter a problem when I try to publish or unpublish content. When attempting to do so, I get several CCK error messages which read:
warning: Invalid argument supplied for foreach() in /home/zowdacom/public_html/modules/cck/content.module on line 1244.
warning: Invalid argument supplied for foreach() in /home/zowdacom/public_html/modules/cck/content.module on line 1284.
warning: Invalid argument supplied for foreach() in /home/zowdacom/public_html/modules/cck/content.module on line 1284.
warning: Invalid argument supplied for foreach() in /home/zowdacom/public_html/modules/cck/includes/content.token.inc on line 39.
My code is below. The error only occurs when this code block is triggered:
function remove_all_terms($node, $old_term_array){
foreach($old_term_array as $key){
$node = rules_action_taxonomy_term_remove_from_content($node, $key, $settings);}
return $node;
}
$vid = $taxonomy_vocab->vid;
$oldterms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
$old_term_array = $oldterms;
$node = remove_all_terms($node, $old_term_array);
return array("node" => $node[node]);
A final symptom of this problem is that a new node is created at the same time that the error message occurs. The node is blank. It has no title, no content, it doesn't even have a type. The only thing it has is an author name "visitor".
This is a major problem for me, because I need this replacement functionality. If anyone could help shed some light on this, it would be appreciated.
Comments
Comment #1
melchoir55 CreditAttribution: melchoir55 commentedI need to start writing out my problems and posting them to pretend message boards because posting seems to lead to me solving the problem immediately.
What happened above is that last line was returning an empty variable for reasons that are reasons. The fix is to replace the final line of that code with
This checks to make sure the variable exists before passing it.
Comment #2
ryguy_colorado CreditAttribution: ryguy_colorado commentedHello, I am having the same problem you described. Could you give me (a knucklehead) a little clarification? Where is that line of code? in the CCK mod' or elsewhere? Thanks.
Comment #3
TR CreditAttribution: TR commented