First an explanation of what we are doing.
We created a rule (using the rules module) for automatically publishing forum posts. The rule takes into account the "type of moderation" of the forum, which can be unmoderated, moderated on a per user basis, or fully moderated. When the forum is moderated on a per user basis, the "moderation status" of the user kicks in. That is, if the user is "moderated", his/her posts/comments will not be published automatically.
We were only able to do this using some custom PHP code in the rule that uses the $node representation available at that time. The rule is triggered by the "content is going to be saved" event.
We also have a command in the mailbox configuration "taxonomy[vid]: [tid]" (where vid is the vocabulary id and tid is the term id).
Now to the bug, a forum post created through the web interface has it's taxonomy (the forum) represented in the following format:
taxonomy => Array( [vid] => [tid] )
A forum post created through an email has it's taxonomy represented in the following format:
taxonomy => Array( [0] => [tid] )
We traced the bug to the mailhandler_process_message() function in the mailhandler.retrieve.inc module.
The explode() function creates an array with default numeric keys starting at 0. The vid is retrieved in line 294, but not used in populating the taxonomy field. Thus the tid is stored (by the array_merge() function in line 303) under key 0, the key provided by the explode() function on line 283.
This also leads to some more questions, which we do not have an answer to:
1) How should the taxonomy field be representing data from multiple vocabularies?
2) How should the taxonomy filed be representing data from a multi value vocabulary (which by the way should not be the one used for the forums, as a topic can only be posted in one forum at a time by design)?
Another issue involves the mailhandler_term_map() function in the same mailhandler.retrieve.inc module. When there is a command taxonomy[vid]: [tid] in your mailbox configuration the tid is not checked on its type (!is_numeric()). So, when the tid delivered is numeric it will fail to find it and return an empty value. As a consequence the taxonomy field is not populated at all.
We created a single patch on version 6.x-1.8 for both issues that seems to be working for us.
| Comment | File | Size | Author |
|---|---|---|---|
| mailhandler.retrieve.inc_.patch | 1.3 KB | Jan van Diepen |
Comments
Comment #1
Ian Ward commentedThanks for reporting. I committed a fix for this, but in a different way. The user func in the array_walk (mailhandler_term_map) can now be called optionally w/ a vid, which will help select the correct tid when giving a vid in the commands. To answer your questions:
1) taxonomy[3]: [foo, bar, baz] will assign those three terms to the node from vid 3.
2) Use commands like:
taxonomy[3]: [foo, bar]
taxonomy[1]: [foo, bar]
which will assign foo from vid 1 and 3 and bar from vid 1 and 3 to the node.
taxonomy_node_save is overloaded to handle an array of terms, a term object, or a term tid. Please reopen if any part of the issue is unresolved or your questions are not answered.