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/#/229 Fix fatal error on send test mail #12399
Conversation
(Standard links)
|
api/v3/Mailing.php
Outdated
@@ -613,19 +614,24 @@ function civicrm_api3_mailing_send_test($params) { | |||
if (!array_key_exists('test_group', $params) && !array_key_exists('test_email', $params)) { | |||
throw new API_Exception("Mandatory key(s) missing from params array: test_group and/or test_email field are required"); | |||
} | |||
civicrm_api3_verify_mandatory($params, |
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.
moved to the spec function
@@ -679,8 +685,7 @@ function civicrm_api3_mailing_send_test($params) { | |||
} | |||
|
|||
$isComplete = FALSE; | |||
$config = CRM_Core_Config::singleton(); |
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.
unused
@@ -410,8 +410,10 @@ public function testMailerSendTest_email() { | |||
$mail = $this->callAPISuccess('mailing', 'create', $this->_params); | |||
|
|||
$params = array('mailing_id' => $mail['id'], 'test_email' => 'alice@example.org', 'test_group' => NULL); | |||
// Per https://lab.civicrm.org/dev/core/issues/229 ensure this is not passed through! | |||
$params['id'] = $mail['id']; |
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.
@eileenmcnaughton how has this test been passing is it just that there isn't a difference in ids between the civicrm_mailing table the civicrm_mailing_job table here?
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.
@seamuslee001 I was able to replicate it when I added to the test so it wasn't transposing 'mailing_id' to 'id' in the api wrapper (I haven't fully thought that through) -
in the api 'id' refers to mailing_id - but is passed to MailingJob as if it were MailingJob id - hence the bug
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.
(mailing id is supposed to be required here & it makes sense it should be)
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.
hmm interesting. So the test was succeeding in that it was setting a mailing_id but no id but once the id got set then it started failing is that the case?
api/v3/Mailing.php
Outdated
|
||
$testEmailParams = _civicrm_api3_generic_replace_base_params($params); |
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.
@eileenmcnaughton is this where the transposition was going on?
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.
@eileenmcnaughton do you think it might be worth adding id to the exclusion on the replace_base_params function instead?
api/v3/Mailing.php
Outdated
FALSE | ||
); | ||
$testEmailParams = [ | ||
'mailing_id' => $params['mailing_id'], |
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.
@eileenmcnaughton your 100% mailing_id is always getting passed as param right?
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.
@seamuslee001 it's a required field - ie I moved a verify_mandatory call to a spec declaration
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.
ok happy with that then
After chatting with Eileen on matermost i am good with these changes @eileenmcnaughton @jmcclelland |
OK - let's merge-on-pass & then @jmcclelland can test the new tarball |
@eileenmcnaughton should we do the same with my PR as well? |
Tested and it works - thank you! Although I'm not sure why the tests are now failing. |
It seems that Mailing.send_test ignores the email_group parameter. |
I just created an alternative that tries to fix the test errors by adding the ability to send to a group: |
Merging as per the testing of @jmcclelland and as per the tag |
Overview
Fixes regression in rc whereby test mailings are not sent
https://lab.civicrm.org/dev/core/issues/229
Before
sending test email fails with: Error in call to Mailing_send_test : job_id is not valid : 440
After
send mail works
Technical Details
@jmcclelland can you please test this? I think that passing params through to the BAO on a different entity is a bad practice so I switched to a whitelist approach.
The original MailingJob::Create only handled the 4 params still being handled
Comments
Thank you for testing the rc @jmcclelland