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

CRM-20800 fix fatal error up updating paypal contributions #10986

Merged
merged 2 commits into from
Nov 29, 2017

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Sep 16, 2017

Overview

Fix for Paypal cancel link giving fatal errors in some circumstances,

Technical Details

I have not been able to replicate this but am hoping the reporter can fix this. The code is an improvement as it is loading the payment processor directly based on the recurring contribution id rather than using an indirect method that we should view as legacy


@seamuslee001
Copy link
Contributor

Jenkins test this please

@seamuslee001
Copy link
Contributor

Jenkins test this please

$this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
if (!$this->_paymentProcessor) {
try {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually it needs to be $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID);

I think, but the issue is a bit more than this. I think it's about making it so a cancellation happens if UI changes (changing installment number, end_date) effectively cancel it. I think it might be easier to change installments on the form when end_date changes - or force user to & possibly move this to the ContributionRecur BAO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree of what need to be addressed, I made the revert to fix a issue mentioned by reporter - https://issues.civicrm.org/jira/browse/CRM-20800?focusedCommentId=108162&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-108162

I though the same but then $this->_paymentProcessor will be set to NULL which later assigned at L140. Although I found no use of $this->_paymentProcessor anywhere in UpdateSubscription php or template, so we might need to keep any one form variable, that would be:

  1. Rename $_paymentProcessorObject to $_paymentProcessor
  2. Remove $_paymentProcessorObject

$this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
if (!$this->_paymentProcessor) {
try {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a hard time in replicating the issue, so I am relying on reporter's response :(

@eileenmcnaughton
Copy link
Contributor Author

@monishdeb I'm going to merge this - it is simply improving the way in which the payment processor is loaded. We collaborated on it before and I have come back to it after so long I feel able to be an 'independent reviewer'. My main concern is that not getting this merged has stalled the JIRA on a critical issue. I think this may not be the fix but I think it will be hard to move forwards without merging it

@eileenmcnaughton eileenmcnaughton merged commit 02fdf2c into civicrm:master Nov 29, 2017
@monishdeb
Copy link
Member

Agree 👍

@eileenmcnaughton
Copy link
Contributor Author

Now we have to try to get the reporter to confirm his current experience....

@@ -87,6 +87,7 @@ public function preProcess() {
catch (CRM_Core_Exception $e) {
CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
}
$this->_paymentProcessorObj = $this->_paymentProcessor['object'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb @eileenmcnaughton I've just run into this line on master and it seems to be breaking the "update subscription" functionality for me. I'm using the smartdebit extension and I get a php crash because $this->_paymentProcessorObj is not an object. Running through a debugger the "object" is actually $this->_paymentProcessor and there is no 'object' array element. Do either of you understand what this line is supposed to do - is it something that needs updating in my smartdebit extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg -does this work?

eileenmcnaughton@3bc67dd

The assigns to the tpl seem no longer required - we call the payment processor to determine what fields can be edited & what text should be rendered

$this->editableScheduleFields = $this->_paymentProcessorObj->getEditableRecurringScheduleFields();

$changeHelpText = $this->_paymentProcessorObj->getRecurringScheduleUpdateHelpText();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does! Well I tested UpdateSubscription at least and that seems to work fine with that additional patch

sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
CRM-20800 fix fatal error up updating paypal contributions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants