X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FWeight.php;h=fe8b716d3e842662c667d406d5e50bf0403722b3;hb=f8307138bf292130a628e68f346535b398ae9b63;hp=ec0176c614638e9aebc62023467e0f092e3b25d7;hpb=dedb7e7a49668f62177976deeb2f9f084e91f3fa;p=civicrm-core.git diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index ec0176c614..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(); @@ -271,11 +276,12 @@ class CRM_Utils_Weight { * Field => value to be used in the WHERE. * @param string $queryData * Data to be used, dependent on the query type. - * @param null $additionalWhere - * @param string $orderBy + * @param string|null $additionalWhere + * Optional WHERE field. + * @param string|null $orderBy * Optional ORDER BY field. - * - * @param null $groupBy + * @param string|null $groupBy + * Optional GROU{} BY field. * * @return CRM_Core_DAO * objet that holds the results of the query @@ -352,11 +358,11 @@ class CRM_Utils_Weight { } /** - * @param $rows + * @param array $rows * @param string $daoName * @param string $idName - * @param $returnURL - * @param null $filter + * @param string $returnURL + * @param string|null $filter */ public static function addOrder(&$rows, $daoName, $idName, $returnURL, $filter = NULL) { if (empty($rows)) { @@ -497,7 +503,7 @@ class CRM_Utils_Weight { } /** - * @param $url + * @param string $url */ public static function fixOrderOutput($url) { if (empty($_GET['snippet']) || $_GET['snippet'] !== 'json') {