Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.2.0
-
Fix Version/s: 4.2.1
-
Component/s: CiviContribute
-
Labels:None
Description
The function "CRM_Core_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj'); " sometimes returns null or no object. Any code that calls that function should test for this condition before trying to call a function on a non-existent object.
What I did to fix the issue, was add a check of "is_object( $paymentProcessorObj) " twice in the section of code pasted below.
ie
if ( $paymentProcessorObj->isSupported('cancelSubscription')) {
was changed to
if (is_object( $paymentProcessorObj) && $paymentProcessorObj->isSupported('cancelSubscription')) {
-------------
and
if ($paymentProcessorObj->isSupported('updateSubscriptionBillingInfo')) {
was changed to:
if (is_object( $paymentProcessorObj) && $paymentProcessorObj->isSupported('updateSubscriptionBillingInfo')) {
My entire code fix is below: ( File: CRM/Contribute/Page/Tab.php , around line 123. )
if ($recurID) {
$paymentProcessorObj = CRM_Core_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj');
// print "<br>payment processor obj: ".$paymentProcessorObj;
if (is_object( $paymentProcessorObj) && $paymentProcessorObj->isSupported('cancelSubscription')) {
unset(self::$_links[CRM_Core_Action::DISABLE]['extra'], self::$_links[CRM_Core_Action::DISABLE]['ref']);
self::$_links[CRM_Core_Action::DISABLE]['url'] = "civicrm/contribute/unsubscribe";
self::$_links[CRM_Core_Action::DISABLE]['qs'] = "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}";
}
if (is_object( $paymentProcessorObj) && $paymentProcessorObj->isSupported('updateSubscriptionBillingInfo')) {
self::$_links[CRM_Core_Action::RENEW] = array('name' => ts('Change Billing Details'),
'title' => ts('Change Billing Details'),
'url' => 'civicrm/contribute/updatebilling',
'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}",
);
}
}