returns weight 0 when weight column name is empty
authorAlain Benbassat <alain@businessandcode.eu>
Thu, 23 Jun 2022 21:00:47 +0000 (23:00 +0200)
committerColeman Watts <coleman@civicrm.org>
Thu, 23 Jun 2022 22:11:35 +0000 (18:11 -0400)
CRM/Utils/Weight.php

index 843115bff3c698d2389839200408333e1bd9dd2a..fe8b716d3e842662c667d406d5e50bf0403722b3 100644 (file)
@@ -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();