Skip to content

Commit

Permalink
Fix PaypalIPN single function to not receive-by-reference
Browse files Browse the repository at this point in the history
The function is called from 2 places
- main
- recur

In both cases it is at the end of the function & so the vars, if altered, are not used again.
In the case of main they are internal to the function whereas for recur they are not returned to the
calling function
  • Loading branch information
eileenmcnaughton committed Aug 2, 2020
1 parent 779251f commit 8480170
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions CRM/Core/Payment/PayPalIPN.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ public function recur($input, $ids, $objects, $first) {
* @param bool $first
*
* @return void
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE) {
public function single($input, $ids, $objects, $recur = FALSE, $first = FALSE) {
$contribution = &$objects['contribution'];

// make sure the invoice is valid and matches what we have in the contribution record
Expand All @@ -257,15 +259,15 @@ public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE
}

$status = $input['paymentStatus'];
if ($status == 'Denied' || $status == 'Failed' || $status == 'Voided') {
if ($status === 'Denied' || $status === 'Failed' || $status === 'Voided') {
$this->failed($objects);
return;
}
if ($status === 'Pending') {
Civi::log()->debug('Returning since contribution status is Pending');
return;
}
elseif ($status == 'Refunded' || $status == 'Reversed') {
elseif ($status === 'Refunded' || $status === 'Reversed') {
$this->cancelled($objects);
return;
}
Expand Down Expand Up @@ -369,7 +371,7 @@ public function main() {
return;
}
}
$this->single($input, $ids, $objects, FALSE, FALSE);
$this->single($input, $ids, $objects);
}

/**
Expand Down

0 comments on commit 8480170

Please sign in to comment.