Skip to content

Commit

Permalink
Merge pull request #25676 from eileenmcnaughton/cust_it
Browse files Browse the repository at this point in the history
Stop passing invariable variables to private function
  • Loading branch information
colemanw authored Mar 7, 2023
2 parents db5fdfd + d0b8699 commit 82e25c6
Showing 1 changed file with 14 additions and 28 deletions.
42 changes: 14 additions & 28 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -1607,12 +1607,12 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
}

// handle custom fields
$mainTree = self::getTree($main['contact_type'], NULL, $mainId, -1,
CRM_Utils_Array::value('contact_sub_type', $main), NULL, TRUE, NULL, TRUE,
$mainTree = self::getTree($main['contact_type'], $mainId,
$main['contact_sub_type'] ?? NULL,
$checkPermissions ? CRM_Core_Permission::EDIT : FALSE
);
$otherTree = self::getTree($main['contact_type'], NULL, $otherId, -1,
CRM_Utils_Array::value('contact_sub_type', $other), NULL, TRUE, NULL, TRUE,
$otherTree = self::getTree($main['contact_type'], $otherId,
$other['contact_sub_type'] ?? NULL,
$checkPermissions ? CRM_Core_Permission::EDIT : FALSE
);

Expand Down Expand Up @@ -1685,26 +1685,16 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
*
* @param string $entityType
* Of the contact whose contact type is needed.
* @param array $toReturn
* What data should be returned. ['custom_group' => ['id', 'name', etc.], 'custom_field' => ['id', 'label', etc.]]
* @param int $entityID
* @param int $groupID
* @param array $subTypes
* @param string $subName
* @param bool $fromCache
* @param bool $onlySubType
* Only return specified subtype or return specified subtype + unrestricted fields.
* @param bool $returnAll
* Do not restrict by subtype at all. (The parameter feels a bit cludgey but is only used from the
* api - through which it is properly tested - so can be refactored with some comfort.)
* @param bool|int $checkPermission
* Either a CRM_Core_Permission constant or FALSE to disable checks
*
* @return array
* Custom field 'tree'.
*
* The returned array is keyed by group id and has the custom group table fields
* and a subkey 'fields' holding the specific custom fields.
* and a sub-key 'fields' holding the specific custom fields.
* If entityId is passed in the fields keys have a subkey 'customValue' which holds custom data
* if set for the given entity. This is structured as an array of values with each one having the keys 'id', 'data'
*
Expand All @@ -1716,20 +1706,16 @@ public static function getRowsElementsAndInfo($mainId, $otherId, $checkPermissio
*/
private static function getTree(
$entityType,
$toReturn = [],
$entityID = NULL,
$groupID = NULL,
$subTypes = [],
$subName = NULL,
$fromCache = TRUE,
$onlySubType = NULL,
$returnAll = FALSE,
$checkPermission = CRM_Core_Permission::EDIT
$entityID,
$subTypes,
$checkPermission
) {
if ($checkPermission === TRUE) {
CRM_Core_Error::deprecatedWarning('Unexpected TRUE passed to CustomGroup::getTree $checkPermission param.');
$checkPermission = CRM_Core_Permission::EDIT;
}
$toReturn = NULL;
$groupID = -1;
$fromCache = TRUE;
$subName = NULL;
$onlySubType = NULL;
$returnAll = TRUE;
if ($entityID) {
$entityID = CRM_Utils_Type::escape($entityID, 'Integer');
}
Expand Down

0 comments on commit 82e25c6

Please sign in to comment.