From db1aa0d1f32215d68080dbd9286dd4dcc7cd705b Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 22 Dec 2019 18:40:58 +1300 Subject: [PATCH] Switch static var to using Civi::statics This static variable is actually problematic. Moving it to statics will allow us to stop reseting it in the test suite & to hone in on where it is actually broken rather than the test suite is not flushing it --- CRM/Member/BAO/Membership.php | 10 ++++++---- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) 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');