Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#448 smart groups as mailing lists were not taking unsubscribed users into… #12943

Closed
wants to merge 1 commit into from

Conversation

tmannell
Copy link

@tmannell tmannell commented Oct 16, 2018

Overview

When using a smart group as a mailing list, users who unsubscribe from the smart group are still included in the mailing.

Before

In civi 5.3 and it seems like in the master branch this isn't accounted for: When creating a mailing using a smart group as a mailing list, users who have previously unsubscribed from the smart group mailing list will still receive the mailing.

After

Users who have unsubscribed form smart group mailing lists and are marked as removed in the civicrm_group_contact table, no longer receive the mailings.

Technical Details

In CRM/Mailing/BAO/Mailing.php the query below doesn't join to the civicrm_group_contact to check if the recipient has been removed.

if (count($includeSmartGroupIDs)) {
      $query = CRM_Utils_SQL_Select::from($contact)
        ->select("$contact.id as contact_id, $entityTable.id as $entityColumn")
        ->join($entityTable, " INNER JOIN $entityTable ON $entityTable.contact_id = $contact.id ")
        ->join('gc', " INNER JOIN civicrm_group_contact_cache gc ON $contact.id = gc.contact_id ")
        ->join('mg', " INNER JOIN civicrm_mailing_group mg  ON  gc.group_id = mg.entity_id AND mg.search_id IS NULL ")
        ->join('temp', " LEFT JOIN $excludeTempTablename temp ON $contact.id = temp.contact_id ")
        ->where('gc.group_id IN (#groups)')
        ->merge($criteria)
        ->replaceInto($includedTempTablename, array('contact_id', $entityColumn))
        ->param('#groups', $includeSmartGroupIDs)
        ->param('#mailingID', $mailingID)
        ->execute();
    }

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@civibot
Copy link

civibot bot commented Oct 16, 2018

(Standard links)

@civibot civibot bot added the 5.3 label Oct 16, 2018
@seamuslee001 seamuslee001 changed the title smart groups as mailing lists were not taking unsubscribed users into… dev/core#448 smart groups as mailing lists were not taking unsubscribed users into… Oct 16, 2018
@eileenmcnaughton
Copy link
Contributor

Closing as this has been pulled into #12945 - the 5.3 branch is not still adding changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants