Skip to content

Commit

Permalink
Merge pull request #24 from moreonion/deleted-taxonomy-terms
Browse files Browse the repository at this point in the history
fix: Don’t send null values for deleted taxonomy terms
  • Loading branch information
torotil authored Oct 30, 2023
2 parents 8470080 + 65e3a48 commit f2eb927
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion integrations/campaignion_source_tags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ function campaignion_source_tags_campaignion_logcrm_event_data_alter(array &$dat
$wrapped_node = entity_metadata_wrapper('node', $node);
$uuid_to_property = array_flip($tags_map);
foreach ($wrapped_node->supporter_tags->value() as $term) {
// Add each tag with a matching parent to its tags-array.
// References to deleted terms yield NULL values here: Remove them.
if (!$term) {
continue;
}
// Add each tag with a matching parent to- its tags-array.
foreach (taxonomy_get_parents($term->tid) as $pterm) {
if ($property = $uuid_to_property[$pterm->uuid] ?? NULL) {
$data['action']["{$property}_tags"][] = $term->name;
Expand Down
5 changes: 4 additions & 1 deletion integrations/campaignion_supporter_tags.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function campaignion_supporter_tags_campaignion_logcrm_event_data_alter(array &$
if (!empty($node->supporter_tags)) {
$wrapped_node = entity_metadata_wrapper('node', $node);
foreach ($wrapped_node->supporter_tags->value() as $term) {
$data['action']['tags'][] = $term->name;
// References to deleted terms yield NULL values here: Remove them.
if ($term) {
$data['action']['tags'][] = $term->name;
}
}
}
}
Expand Down

0 comments on commit f2eb927

Please sign in to comment.