CRM-20035 credit card backend contribution alters communication preferences

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.16
    • Fix Version/s: 4.7.25
    • Component/s: None
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No

      Description

      to reproduce:

      1. open a contact and flag several communication preferences
      2. complete a credit card contribution for the contact
      3. reload the contact and view the comm preferences

      any previously selected values will be gone.
      it's possible this is related to: CRM-19933

        Attachments

          Activity

          [CRM-20035] credit card backend contribution alters communication preferences
          Eileen McNaughton added a comment -

          I have a feeling that this might get fixed as a byproduct of some other stuff I've been doing on search - will test

          Brian Shaughnessy added a comment -

          Eileen McNaughton did you get a chance to test this?
          I was going to invest some time into troubleshooting this, unless you can confirm it's fixed in imminent changes you will be implementing.

          Eileen McNaughton added a comment -

          I haven't tested it, but I have made changes in the area. If it's still a problem I'm happy to work with you on fixing it

          Brian Shaughnessy added a comment -

          confirmed that it's still broken in core

          Brian Shaughnessy added a comment -

          https://github.com/civicrm/civicrm-core/pull/9972

          this issue is the result of workarounds for preferred_communication_method in CRM_Contact_BAO_Contact::add

          around line 154 we have code to handle preferred_communication_method, which accounts for two scenarios:
          1) if the array key is not passed, we set an empty value (allow intentional unsetting of existing values)
          2) if values are passed, reformat as array

          unfortunately, this means that if the array key is not passed because we are ignoring the field, it's treated like the first scenario, and sets the values to empty. in this case, the method is originating from CRM_Contribution_Form_Contribution::processCreditCard() where we processBillingAddress (around line 1147).

          there's no clear way to address this in the contact BAO. we legitimately need to handle the situation where no passed array element means we are removing existing values. so although it feels a bit hackish, I think we need to always pass the existing preferred_communication_method values from the contribution form.

          as far as I could see, this issue only affects this form, and only because we're updating the contact record via the billing address.

          Eileen McNaughton added a comment -
          Brian Shaughnessy added a comment -

          yes it does – just applied the PR and ran through these tests and the comm prefs were preserved.

          I'll close out my PR in favor of yours. 

          Eileen McNaughton added a comment -

          OK great. I see Monish has engaged on my PR & it is not 100% there yet but we'll keep working on that. Will be nice to get this fixed as I think it's a bug that has a lot of 'faces'

            People

            • Assignee:
              Monish Deb
              Reporter:
              Brian Shaughnessy

              Dates

              • Created:
                Updated:
                Resolved: