Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 3.4.6
-
Fix Version/s: 3.4.7
-
Component/s: CiviContribute
-
Labels:None
Description
We are seeing the following error when modifying existing contributions:
"warning: Invalid argument supplied for foreach() in /home/www/drupal/sites/mydomain.org/modules/civicrm/CRM/Contribute/BAO/Contribution.php on line 1439."
the error seems to occur nearly every time a transaction record is edited. the changes are saved just fine, but the error is displayed to the user.
eileen says: looks like that line of code needs an if(is_array) around it, and provides this, via pastebin http://pastebin.com/bp0NW2fJ
Index: CRM/Contribute/BAO/Contribution.php
===================================================================
— CRM/Contribute/BAO/Contribution.php (revision 36508)
+++ CRM/Contribute/BAO/Contribution.php (working copy)
@@ -1460,7 +1460,8 @@
if ( $processContributionObject ) $processContribution = true;
}
} else if ( $contributionStatusId == array_search( 'Failed', $contributionStatuses ) ) {
- foreach ($memberships as $membership) {
+ if(is_array($memberships)){
+ foreach ($memberships as $membership) {
if ( $membership ) { $membership->status_id = array_search( 'Expired', $membershipStatuses ); $membership->save( ); @@ -1469,6 +1470,7 @@ if ( $processContributionObject ) $processContribution = true; }
+ }
}
if ( $participant ) {
$updatedStatusId = array_search( 'Cancelled', $participantStatuses );