Skip to content
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/#133 Make Conditions Stricter When Checking If Reply-To Field Is Empty #12176

Merged

Conversation

vinuvarshith
Copy link
Contributor

Overview

reply-to field is NULL in the following case

  • Add a new mailing (or reuse one)
  • Select a 'reply to' email (I had to enable "Enable Custom Reply-To" in 'civicrm/admin/mail')
  • Fill in other fields as usual
  • Under 'Responses' tab, check "Track Replies" checkbox. This brings up a warning message on the top right saying 'reply-to' has been cleared out (but still allows user to save mailing)
  • Proceed to next step and save mailing

Technical Details

In CRM_Mailing_BAO_Mailing.php when adding a new mailing (add() method), there is a condition to check if 'reply-to' field is set and if it is not set, then 'from-email' is used.
here instead if using
if(!isset($params['replyto_email']))
we should use
if(empty($params['replyto_email']))
so that empty string like '' will also be considered and reply-to could not be NULL

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

I think this is pretty compelling. My feeling is we should probably also only set it if id is empty though as we don't want to overwrite the reply_to if the subject is being updated by the api. I was going to merge on the basis this would be 'no worse' on that front but I'm not sure actually - it might expose more pathways to that 'bug'

@seamuslee001
Copy link
Contributor

@eileenmcnaughton well I think this probably safe to merge on its own, we also need to take into account the situation say where you have updated the from email address so now the reply to also needs to be updated as well.

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 how do we differentiate that though?

It seems like setting the reply address from the from address would be always correct when there is no id & sometimes correct when there is an id and it's hard to know when, unless the calling function handles it. This change increases the cases in which the BAO would make a guess about what the calling function really intended.

Perhaps we need to handle this defaulting at the form level not the BAO ?

@seamuslee001
Copy link
Contributor

@eileenmcnaughton well its hard to tell i tend to think that empty is better than isset here in general, Interms of setting the reply to base on the from that isn't always the case either sometimes people will specifically set a separate reply to address compared to the from, I think form level maybe more sensible of course form level here = angular not Quickform / smarty

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I agree empty is better but changing at the BAO level has a risk of unintended consequences (although I think that risk is only on updates).

@vinuvarshith
Copy link
Contributor Author

@eileenmcnaughton
I thought empty was better than isset in this case. But what do you suggest then to keep users from saving a mailing with empty value for 'reply to' field? Pls let me know and I will try to address that.
Thanks

@eileenmcnaughton
Copy link
Contributor

I would be ok with

if ((!$id && empty($params['replyto_email'])) || !isset($params['replyto_email'])

which would retain the existing behaviour on update but would be more aggressive on new.

If we want to be more aggressive on update I think we should do that at the form layer

…To Field Is Empty

dev/core/civicrm#133 Retain existing behaviour on update and only be aggressive on adding new
@vinuvarshith vinuvarshith force-pushed the dev-core-133-reply-to-check branch from 5600aae to d3521e4 Compare June 18, 2018 19:35
@vinuvarshith
Copy link
Contributor Author

@eileenmcnaughton
I have updated the condition as you have suggested. So existing behaviour is retained on update.

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Jun 18, 2018

great - merging. For updates we should fix at the form level

@eileenmcnaughton eileenmcnaughton merged commit 907d4bb into civicrm:master Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants