Skip to content

Commit

Permalink
Merge pull request #16138 from eileenmcnaughton/static
Browse files Browse the repository at this point in the history
Switch static var to using Civi::statics
  • Loading branch information
mattwire authored Dec 22, 2019
2 parents 574cf20 + db1aa0d commit 6c97b63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 6 additions & 4 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1334,13 +1334,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

0 comments on commit 6c97b63

Please sign in to comment.