Skip to content

Ensure campaign recipients are deduped across multiple lists - #86

Merged
katsar0v merged 12 commits into
mainfrom
copilot/fix-multiple-lists-email-sending
Dec 19, 2025
Merged

Ensure campaign recipients are deduped across multiple lists#86
katsar0v merged 12 commits into
mainfrom
copilot/fix-multiple-lists-email-sending

Conversation

Copilot AI commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Campaigns targeting multiple lists could queue duplicate emails for subscribers present in more than one list. One-time sends remain unaffected.

  • Deduplication before queueing: Added subscriber de-duplication (by email and ID) in Email_Service::queue_campaign to guarantee each recipient is queued once even if they appear in multiple lists.
  • Test coverage: Added a unit test confirming duplicates across lists are removed before queue generation.

Example:

$campaign_id = $email_service->queue_campaign( array(
    'subject'     => 'Update',
    'body'        => '<p>Hello</p>',
    'list_ids'    => array( 1, 2 ),
    'subscribers' => array(
        (object) array( 'id' => 10, 'email' => 'dup@example.com' ),
        (object) array( 'id' => 11, 'email' => 'unique@example.com' ),
        (object) array( 'id' => 10, 'email' => 'dup@example.com' ), // deduped
    ),
) );
// Only two queue entries are created despite the duplicate

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/d95a9d895352c30f47604ad1b825ab8fa9d1a373
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/antecedent/patchwork/zipball/8b6b235f405af175259c8f56aea5fc23ab9f03ce
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/composer/installers/zipball/12fb2dfe5e16183de69e784a7b84046c43d97e8e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)
  • https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ORxdiz /usr/bin/composer install (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Multiple lists in a campaign</issue_title>
<issue_description>What happens when multiple lists are selected in a campaign? If a subscriber is in two lists, he should get the email only once even if the campaign is targeting multiple lists.</issue_description>

<agent_instructions>Analyze campaign and one-time email sending behavior</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix email sending for multiple lists in a campaign Ensure campaign recipients are deduped across multiple lists Dec 19, 2025
Copilot AI requested a review from katsar0v December 19, 2025 09:16
Copilot AI and others added 11 commits December 19, 2025 10:21
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
Co-authored-by: katsar0v <7236157+katsar0v@users.noreply.github.com>
@katsar0v
katsar0v force-pushed the copilot/fix-multiple-lists-email-sending branch from 3dbab67 to 53f81b4 Compare December 19, 2025 09:23
@katsar0v
katsar0v marked this pull request as ready for review December 19, 2025 09:26
@katsar0v
katsar0v merged commit 23776f3 into main Dec 19, 2025
4 of 6 checks passed
@katsar0v
katsar0v deleted the copilot/fix-multiple-lists-email-sending branch December 19, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple lists in a campaign

2 participants