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

Switch static var to using Civi::statics #16138

Merged
merged 1 commit into from
Dec 22, 2019
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
10 changes: 6 additions & 4 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1331,13 +1331,15 @@ public static function sortName($id) {
*/
public static function createRelatedMemberships(&$params, &$dao, $reset = FALSE) {
// CRM-4213 check for loops, using static variable to record contacts already processed.
static $relatedContactIds = [];
if (!isset(\Civi::$statics[__CLASS__]['related_contacts'])) {
\Civi::$statics[__CLASS__]['related_contacts'] = [];
}
if ($reset) {
// We need a way to reset this static variable from the test suite.
// @todo consider replacing with Civi::$statics but note reset now used elsewhere: CRM-17723.
$relatedContactIds = [];
// CRM-17723.
unset(\Civi::$statics[__CLASS__]['related_contacts']);
return FALSE;
}
$relatedContactIds = &\Civi::$statics[__CLASS__]['related_contacts'];

$membership = new CRM_Member_DAO_Membership();
$membership->id = $dao->id;
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1838,8 +1838,6 @@ public function quickCleanUpFinancialEntities() {
$this->quickCleanup($tablesToTruncate);
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_membership_status WHERE name NOT IN('New', 'Current', 'Grace', 'Expired', 'Pending', 'Cancelled', 'Deceased')");
$this->restoreDefaultPriceSetConfig();
$var = TRUE;
CRM_Member_BAO_Membership::createRelatedMemberships($var, $var, TRUE);
$this->disableTaxAndInvoicing();
$this->setCurrencySeparators(',');
CRM_Core_PseudoConstant::flush('taxRates');
Expand Down