Merge pull request #24022 from colemanw/afformFrontend
[civicrm-core.git] / CRM / Utils / Weight.php
index ec0176c614638e9aebc62023467e0f092e3b25d7..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();
@@ -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') {