Skip to content

Commit

Permalink
Switch static var to using Civi::statics
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eileenmcnaughton committed Dec 22, 2019
1 parent 2ca9b2e commit 65a1a2a
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 @@ -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

0 comments on commit 65a1a2a

Please sign in to comment.