When using taxonomy as a condition in CA, the actions were never executed, the problem is located at line 120 in uc_discount.ca.inc, I changed to code as follows, because $terms can be a string/number
// Get the chosen terms that the node actually has.
if (is_array($terms)) {
$has_terms = array_intersect($terms, $node_terms);
}
else {
$has_terms = in_array($terms, $node_terms);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | node_category.patch | 1.17 KB | Island Usurper |
Comments
Comment #1
henrrrik commentedI've found a couple of problems in
uc_discount_condition_node_term()in uc_discount.ca.inc.taxonomy_node_get_terms()fails on$nodebecause$nodeisn't a fully populated node object in this context and$node->vidis empty. Anode_load()solves this, but I assume real problem is located in ca.module.array_intersect()fails if there's only one term. However,is_array()only returns a bool result, not the term id. I replaced it with this:Comment #2
Island Usurper commentedI want to avoid doing node_load() in condition and action code, because they might be used during a View's construction. Doing all those extra node_load()s would be too big a performance hit. That said, I've resorted to using a database call anyway to get the $node->vid if it isn't there. Hopefully that won't be too bad.
It's also a lot easier just to force $terms to be an array than to do different things whether it is or not.
Comment #3
Island Usurper commentedCommitted, since I haven't heard anything back.