Skip to content

Commit

Permalink
Merge pull request #16260 from eileenmcnaughton/ids_2
Browse files Browse the repository at this point in the history
[REF] Fix CRM_Core_BAO_UFGroup::createUFJoin to not receive by reference.
  • Loading branch information
eileenmcnaughton authored Jan 22, 2020
2 parents c8fd50e + 259ab03 commit b05b03e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions CRM/Core/BAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1477,13 +1477,13 @@ public static function add(&$params, $ids = []) {
/**
* Make uf join entries for an uf group.
*
* @param array $params
* (reference) an assoc array of name/value pairs.
* @param int $weight
* @param array $groupTypes
* An assoc array of name/value pairs.
* @param int $ufGroupId
* Ufgroup id.
*/
public static function createUFJoin(&$params, $ufGroupId) {
$groupTypes = CRM_Utils_Array::value('uf_group_type', $params);
public static function createUFJoin($weight, $groupTypes, $ufGroupId) {

// get ufjoin records for uf group
$ufGroupRecord = CRM_Core_BAO_UFGroup::getUFJoinRecord($ufGroupId);
Expand All @@ -1507,7 +1507,7 @@ public static function createUFJoin(&$params, $ufGroupId) {
$joinParams = [];
$joinParams['uf_group_id'] = $ufGroupId;
$joinParams['module'] = $key;
if ($key == 'User Account') {
if ($key === 'User Account') {
$menuRebuild = TRUE;
}
if (array_key_exists($key, $groupTypes) && !in_array($key, $ufGroupRecord)) {
Expand All @@ -1521,14 +1521,14 @@ public static function createUFJoin(&$params, $ufGroupId) {
}

//update the weight
$query = "
$query = '
UPDATE civicrm_uf_join
SET weight = %1
WHERE uf_group_id = %2
AND ( entity_id IS NULL OR entity_id <= 0 )
";
';
$p = [
1 => [$params['weight'], 'Integer'],
1 => [$weight, 'Integer'],
2 => [$ufGroupId, 'Integer'],
];
CRM_Core_DAO::executeQuery($query, $p);
Expand Down
2 changes: 1 addition & 1 deletion CRM/UF/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public function postProcess() {

if (!empty($params['is_active'])) {
//make entry in uf join table
CRM_Core_BAO_UFGroup::createUFJoin($params, $ufGroup->id);
CRM_Core_BAO_UFGroup::createUFJoin($params['weight'], $params['uf_group_type'] ?? [], $ufGroup->id);
}
elseif ($this->_id) {
// this profile has been set to inactive, delete all corresponding UF Join's
Expand Down

0 comments on commit b05b03e

Please sign in to comment.