From 4f2060b873c9137cdb13e323ea7bce7d5e16e5b7 Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 13 Oct 2023 20:51:44 -0400 Subject: [PATCH] dev/core#4364 - Don't reset weights when updating managed entity --- CRM/Core/ManagedEntities.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Core/ManagedEntities.php b/CRM/Core/ManagedEntities.php index daacdca7a5..82b03bc1f2 100644 --- a/CRM/Core/ManagedEntities.php +++ b/CRM/Core/ManagedEntities.php @@ -291,7 +291,13 @@ class CRM_Core_ManagedEntities { } elseif ($doUpdate && $item['params']['version'] == 4) { $params = ['checkPermissions' => FALSE] + $item['params']; - $params['values']['id'] = $item['entity_id']; + $idField = CoreUtil::getIdFieldName($item['entity_type']); + $params['values'][$idField] = $item['entity_id']; + // Exclude "weight" as that auto-adjusts + if (in_array('SortableEntity', CoreUtil::getInfoItem($item['entity_type'], 'type'), TRUE)) { + $weightCol = CoreUtil::getInfoItem($item['entity_type'], 'order_by'); + unset($params['values'][$weightCol]); + } // 'match' param doesn't apply to "update" action unset($params['match']); try { -- 2.25.1