diff --git a/rules/modules/taxonomy.rules.inc b/rules/modules/taxonomy.rules.inc index cc4751c74b8c092705d11c954f73d219b6eaa476..54e4e626cd11cee453aac1b3f39a91e1a3c291db 100644 --- a/rules/modules/taxonomy.rules.inc +++ b/rules/modules/taxonomy.rules.inc @@ -296,6 +296,10 @@ function taxonomy_rules_condition_info() { */ function rules_condition_content_has_term(&$node, $settings) { + if (!isset($node->taxonomy)) { + return FALSE; + } + $taxonomy = $node->taxonomy; // If vocab is marked as tag, we format it to the proper format. @@ -318,21 +322,23 @@ function rules_condition_content_has_term(&$node, $settings) { unset($taxonomy['tags']); } - - if (isset($taxonomy) && (count($taxonomy) > 0)) { + if ((count($taxonomy) > 0)) { $tids = array(); foreach ($taxonomy as $vocab) { - if (!empty($vocab) && is_array($vocab)) { + if (is_array($vocab)) { foreach ($vocab as $term) { $tid = is_object($term) ? $term->tid : (is_array($term) ? reset($term) : $term); $tids[$tid] = $tid; } } - else { - if (!empty($vocab) && is_numeric($vocab)) { - $tids[$vocab] = $vocab; - } + else if (is_object($vocab)) { + // $vocab really is a term object + $tids[$vocab->tid] = $vocab->tid; + } + else if (is_numeric($vocab)) { + // $vocab really is a term ID + $tids[$vocab] = $vocab; } }