-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
DPMMA-3048 Fix campaign execution stuck due to incorrect lead detachment in membership change action #14497
base: 5.2
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 5.2 #14497 +/- ##
============================================
+ Coverage 63.44% 63.47% +0.02%
- Complexity 34630 34637 +7
============================================
Files 2273 2273
Lines 103594 103609 +15
============================================
+ Hits 65728 65767 +39
+ Misses 37866 37842 -24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happened by accident when the EM->clear() method was removed and the code needed to be refactored in 777e2dc#diff-88261e62c0ae339645adadf9bb77a8efda5a985a11c5c517c7dcf10da734507a
@biozshock can you please review this too?
{ | ||
$campaign1 = $this->createCampaign('Campaign 1'); | ||
// create campaign with restart allowed | ||
$campaign2 = $this->createCampaign('Campaign 2', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can change the campaign in place, allowing later to grasp what's going on without a need to review method signature.
$campaign2 = $this->createCampaign('Campaign 2', true); | |
$campaign2 = $this->createCampaign('Campaign 2'); | |
$campaign2->setAllowRestart(true); |
protected function createCampaign(string $campaignName, bool $allowRestart = false): Campaign | ||
{ | ||
$campaign = new Campaign(); | ||
$campaign->setName($campaignName); | ||
$campaign->setIsPublished(true); | ||
$campaign->setAllowRestart($allowRestart); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of adding more and more parameters to the methods. This ups the cognitive load. Because the campaign is an object you can freely change it whenever needed later in the test.
protected function createCampaign(string $campaignName, bool $allowRestart = false): Campaign | |
{ | |
$campaign = new Campaign(); | |
$campaign->setName($campaignName); | |
$campaign->setIsPublished(true); | |
$campaign->setAllowRestart($allowRestart); | |
protected function createCampaign(string $campaignName): Campaign | |
{ | |
$campaign = new Campaign(); | |
$campaign->setName($campaignName); | |
$campaign->setIsPublished(true); |
This pull request has been mentioned on Mautic Forums. There might be relevant details there: https://forum.mautic.org/t/cron-job-for-campaigns-buggy-5-1-0/33217/6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it in a real application. Before this change I got huge amount of "app.ERROR: CAMPAIGN: Multiple non-persisted new entities were found through the given association graph:" errors and basically every campaign email sending stopped. With this small, but important change everything works as excepted.
Description
The campaign execution was getting stuck due to an issue with lead detachment in the change membership action. The previous implementation was detaching all contacts, including those newly added to the campaign, which caused problems while trying to save the campaign log after detach.
This PR also addresses an issue in the
testCampaignActionChangeMembership
test. Previously, the test was incorrectly set up: it was adding the contact to both campaigns before executing the campaign action.📋 Steps to test this PR:
Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
Create two empty segments in Mautic.
Create Campaign 1:
Create Campaign 2:
Add a contact to Segment 2 and run the campaigns:
Verify that the campaign execution was successful.
Check if the created contact is now a member of Campaign 1.