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

[NFC] Code cleanup #16309

Merged
merged 1 commit into from
Jan 17, 2020
Merged
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
17 changes: 10 additions & 7 deletions CRM/Contact/BAO/GroupNestingCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ class CRM_Contact_BAO_GroupNestingCache {
/**
* Update cache.
*
* @throws \Exception
* @throws \CRM_Core_Exception
*/
public static function update() {
// lets build the tree in memory first

$sql = "
$sql = '
SELECT n.child_group_id as child ,
n.parent_group_id as parent
FROM civicrm_group_nesting n,
civicrm_group gc,
civicrm_group gp
WHERE n.child_group_id = gc.id
AND n.parent_group_id = gp.id
";
';

$dao = CRM_Core_DAO::executeQuery($sql);

Expand All @@ -57,15 +57,15 @@ public static function update() {
}

if (self::checkCyclicGraph($tree)) {
CRM_Core_Error::fatal(ts("We detected a cycle which we can't handle. aborting"));
throw new CRM_Core_Exception(ts('We detected a cycle which we can\'t handle. aborting'));
}

// first reset the current cache entries
$sql = "
$sql = '
UPDATE civicrm_group
SET parents = null,
children = null
";
';
CRM_Core_DAO::executeQuery($sql);

$values = [];
Expand Down Expand Up @@ -132,9 +132,10 @@ public static function isCyclic(&$tree, $id) {

/**
* @param int $id
* @param $groups
* @param array $groups
*
* @return array
* @throws \CRM_Core_Exception
*/
public static function getPotentialCandidates($id, &$groups) {
$tree = Civi::cache('groups')->get('nestable tree hierarchy');
Expand Down Expand Up @@ -201,6 +202,8 @@ public static function getAll(&$all, &$tree, $id, $token) {

/**
* @return string
*
* @throws \CRM_Core_Exception
*/
public static function json() {
$tree = Civi::cache('groups')->get('nestable tree hierarchy');
Expand Down