Cron-job for Campaigns buggy (5.1.0)

Your software
My Mautic version is: 5.1.0 (same issue with 5.0.4)
My PHP version is: 8.0.30
My Database type and version is: 10.3.39-MariaDB

Your problem
My problem is:
My campaigns don’t get triggered as they should (despite correct cron-job setup). Even triggering them manually via Terminal with “php bin/console mautic:campaigns:update” and “php bin/console mautic:campaigns:trigger” doesn’t work correctly. The campaigns seem just to trigger (more or less) correctly if I ran the cron-jobs with for example " --campaign-id=12".

These errors are showing in the log:

In the Mautic admin-area the log is empty.

Here is a part of “var/logs/prod-2024-08-22.php” (every few minutes new such entries are added):

[2024-08-22T09:40:03.232683+00:00] app.ERROR: CAMPAIGN: Multiple non-persisted new entities were found through the given association graph: * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#campaign' that was not configured to cascade persist operations for entity: Mautic\CampaignBundle\Entity\Campaign with ID #18. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#campaign' that was not configured to cascade persist operations for entity: Mautic\CampaignBundle\Entity\Campaign with ID #15. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #542. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#campaign' that was not configured to cascade persist operations for entity: Mautic\CampaignBundle\Entity\Campaign with ID #21. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #543. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #544. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #546. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #547. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #548. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #550. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #551. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #552. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #553. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #554. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #555. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #556. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #557. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #558. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #559. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #560. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #561. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #562. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\LeadEventLog#lead' that was not configured to cascade persist operations for entity: Proxies\__CG__\Mautic\LeadBundle\Entity\Lead with ID #563. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). * A new entity was found through the relationship 'Mautic\CampaignBundle\Entity\Lead#campaign' that was not configured to cascade persist operations for entity: Mautic\CampaignBundle\Entity\Campaign with ID #12. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). [] {"hostname":"server.verfuehren-befriedigen-tipps.de","pid":13372}

Steps I have tried to fix the problem:

Despite not understanding the error-code at all, I tried all kinds of AI (chatGTP, etc.) to solve this errors, but with no luck. They say things I don’t understand either, like:

“The error message you’re encountering indicates that Mautic is having trouble persisting certain entities within your campaigns. Specifically, it’s struggling to handle relationships between entities like LeadEventLog, Campaign, and Lead due to missing cascade={"persist"} configurations in the Doctrine ORM mappings.”

This is happening to me as well on 5.2.1

Same on 5.1.1.

What’s the solution? Because the effect of it is huge. All of our campaigns stopped working.

I could fix it with putting the ->cascadePersist() option in the related class mentioned in the log, but there are too many ManyToOne relations in the code. So it should be a global solution I think.

Can you check (somehow) if it happens to new segments as well? Created after the upgrade.

Hi folks,

I think this is related to a bug already reported and fixed according to the logs which are mentioned a few comments down:

Please test the fix:

1 Like

Thank you! :slight_smile: I will test it!

@rcheesley it seems to be working! Thank you! :slight_smile:

That’s great @miki - it’s very important that you leave a review so we can get this PR merged. Here’s how to do that: https://contribute.mautic.org/contributing-to-mautic/tester#leaving-your-review - thanks in advance!

1 Like