CIVIPLMMSR-568: Ensure scheduled_date is always set when submitting a mailing#206
CIVIPLMMSR-568: Ensure scheduled_date is always set when submitting a mailing#206erawat wants to merge 1 commit into5.75.0-patchesfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where scheduled mailings could silently disappear from the system if their scheduled_date was inadvertently lost during the submission pipeline. By introducing robust defensive checks, it ensures that all mailings with a scheduled_id consistently have a scheduled_date, thereby preventing data loss and ensuring reliable scheduling. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces defensive guards to ensure scheduled_date is set when a mailing is submitted, preventing mailings from being lost. The core logic is added to CRM_Mailing_BAO_Mailing::doSubmitActions, which is a good central place for this safeguard. A similar check is added to api/v3/Mailing.php. My review suggests removing the redundant and less complete check from the API file to rely on the more robust implementation in the BAO layer, which also improves logging consistency.
api/v3/Mailing.php
Outdated
| // Ensure scheduled_date is always set when scheduled_id is present. | ||
| // There are edge cases where scheduled_date can be lost during the create | ||
| // pipeline, resulting in mailings that have a scheduled_id but NULL | ||
| // scheduled_date — which prevents the mail scheduler from ever sending them. | ||
| if (!empty($updateParams['scheduled_id']) && empty($updateParams['scheduled_date'])) { | ||
| $updateParams['scheduled_date'] = date('YmdHis'); | ||
| } |
There was a problem hiding this comment.
This check for scheduled_id and scheduled_date is now redundant due to the more comprehensive logic added in CRM_Mailing_BAO_Mailing::doSubmitActions. The doSubmitActions method is called within this API function's execution path, so this check is not necessary here.
The logic in doSubmitActions is also more robust because it handles cases where scheduled_date is the string 'null' and it logs a warning, which is helpful for debugging.
Removing this block will improve consistency and ensure that a warning is always logged when this fallback is triggered, relying on the single source of truth in the BAO.
3a5e8b1 to
d2b0b32
Compare
d2b0b32 to
f94c13c
Compare
Summary
Patch for CIVIPLMMSR-568: Adds
ensureScheduledDate()private method inCRM_Mailing_BAO_Mailingto prevent mailings from silently disappearing whenscheduled_dateis lost during the submit pipeline. Called from bothadd()anddoSubmitActions().Core PR: civicrm#35126
Patch commit