From: Alain Benbassat Date: Thu, 23 Jun 2022 21:00:47 +0000 (+0200) Subject: returns weight 0 when weight column name is empty X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=22082f910c0cb1b9b6baf938d2ee6d5c8bdc6138;p=civicrm-core.git returns weight 0 when weight column name is empty --- diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index 843115bff3..fe8b716d3e 100644 --- a/CRM/Utils/Weight.php +++ b/CRM/Utils/Weight.php @@ -233,6 +233,11 @@ class CRM_Utils_Weight { * @return int */ public static function getMax($daoName, $fieldValues = NULL, $weightField = 'weight') { + if (empty($weightField)) { + Civi::log()->warning('Missing weight field name for ' . $daoName); + return 0; + } + $selectField = "MAX(ROUND($weightField)) AS max_weight"; $weightDAO = CRM_Utils_Weight::query('SELECT', $daoName, $fieldValues, $selectField); $weightDAO->fetch();