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

[REF] Remove unused parameters #20301

Merged
merged 1 commit into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ private function processMembership(array $params) {
'start_date' => $value['membership_start_date'] ?? NULL,
];
$membershipSource = $value['source'] ?? NULL;
[$membership] = self::legacyProcessMembership(
$membership = self::legacyProcessMembership(
$value['contact_id'], $value['membership_type_id'], FALSE,
//$numTerms should be default to 1.
NULL, NULL, $value['custom'], 1, NULL, FALSE,
Expand Down Expand Up @@ -1038,20 +1038,18 @@ public function testProcessContribution($params) {
* @param $isPayLater
* @param array $memParams
* @param array $formDates
* @param null|CRM_Contribute_BAO_Contribution $contribution
* @param array $lineItems
*
* @return array
* @return CRM_Member_BAO_Membership
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function legacyProcessMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $memParams = [], $formDates = [], $contribution = NULL, $lineItems = []) {
$renewalMode = $updateStatusId = FALSE;
public static function legacyProcessMembership($contactID, $membershipTypeID, $is_test, $changeToday, $modifiedID, $customFieldsFormatted, $numRenewTerms, $membershipID, $pending, $contributionRecurID, $membershipSource, $isPayLater, $memParams = [], $formDates = []): CRM_Member_BAO_Membership {
$updateStatusId = FALSE;
$allStatus = CRM_Member_PseudoConstant::membershipStatus();
$format = '%Y%m%d';
$statusFormat = '%Y-%m-%d';
$membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipType($membershipTypeID);
$dates = [];
$ids = [];

// CRM-7297 - allow membership type to be be changed during renewal so long as the parent org of new membershipType
Expand All @@ -1060,7 +1058,6 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i
$is_test, $membershipID, TRUE
);
if ($currentMembership) {
$renewalMode = TRUE;

// Do NOT do anything.
//1. membership with status : PENDING/CANCELLED (CRM-2395)
Expand All @@ -1073,11 +1070,9 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i

$memParams = array_merge([
'id' => $currentMembership['id'],
'contribution' => $contribution,
'status_id' => $currentMembership['status_id'],
'start_date' => $currentMembership['start_date'],
'end_date' => $currentMembership['end_date'],
'line_item' => $lineItems,
'join_date' => $currentMembership['join_date'],
'membership_type_id' => $membershipTypeID,
'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL,
Expand All @@ -1087,8 +1082,7 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i
$memParams['contribution_recur_id'] = $contributionRecurID;
}

$membership = CRM_Member_BAO_Membership::create($memParams);
return [$membership, $renewalMode, $dates];
return CRM_Member_BAO_Membership::create($memParams);
}

// Check and fix the membership if it is STALE
Expand Down Expand Up @@ -1237,19 +1231,17 @@ public static function legacyProcessMembership($contactID, $membershipTypeID, $i
}
$params['modified_id'] = $modifiedID ?? $contactID;

$memParams['contribution'] = $contribution;
$memParams['custom'] = $customFieldsFormatted;
// Load all line items & process all in membership. Don't do in contribution.
// Relevant tests in api_v3_ContributionPageTest.
$memParams['line_item'] = $lineItems;
// @todo stop passing $ids (membership and userId may be set by this point)
$membership = CRM_Member_BAO_Membership::create($memParams, $ids);

// not sure why this statement is here, seems quite odd :( - Lobo: 12/26/2010
// related to: http://forum.civicrm.org/index.php/topic,11416.msg49072.html#msg49072
$membership->find(TRUE);

return [$membership, $renewalMode, $dates];
return $membership;
Copy link
Member

Choose a reason for hiding this comment

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

Grepped universe for references to legacyProcessMembership - nothing outside of civicrm-core using it.

@eileenmcnaughton Just to double-check, the legacyProcessMembership in CRM/Contribute/Form/Contribution/Confirm.php and CRM/Batch/Form/Entry.php are essentially independent, right? So it looks like this change to the Batch/Form/Entry.php has no interaction with the Confirm.php one.

If so, I'd say go ahead and merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we have unit testes that cover the Confirm.php stuff as well

}

}
10 changes: 7 additions & 3 deletions tests/phpunit/CRM/Batch/Form/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
*
* @var string
*/
protected $_membershipTypeName = NULL;
protected $_membershipTypeName;

/**
* Membership type id used in test function.
*
* @var string
*/
protected $_membershipTypeID = NULL;
protected $_membershipTypeID;

/**
* Contact id used in test function.
Expand Down Expand Up @@ -75,6 +75,10 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
*/
protected $_contactID4 = NULL;

/**
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function setUp(): void {
parent::setUp();

Expand Down Expand Up @@ -120,7 +124,7 @@ public function setUp(): void {
'sequential' => 1,
'visibility' => 'Public',
];
$membershipType2 = $this->callAPISuccess('membership_type', 'create', $params);
$membershipType2 = $this->callAPISuccess('MembershipType', 'create', $params);
$this->_membershipTypeID2 = $membershipType2['id'];

$this->_membershipStatusID = $this->membershipStatusCreate('test status');
Expand Down