diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 7794deef0c9a..4d51b83ef204 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -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; diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 62a72d11add3..91a9fe1ec36a 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -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');