diff --git a/etemplate/inc/class.so_sql.inc.php b/etemplate/inc/class.so_sql.inc.php index e3a83ac757..2338c46e53 100644 --- a/etemplate/inc/class.so_sql.inc.php +++ b/etemplate/inc/class.so_sql.inc.php @@ -1156,6 +1156,8 @@ class so_sql } $alias = $col; if (stripos($col, ' AS ')) list($col, $alias) = preg_split('/ +AS +/i', $col); + // do NOT group by constant expressions + if (preg_match('/^ *(-?[0-9]+|".*"|\'.*\'|NULL) *$/i', $col)) continue; if (!in_array($col, $group_by_cols) && !in_array($alias, $group_by_cols)) { $group_by_cols[] = $alias; diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index 10617c06c6..72b1d9bce8 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -559,9 +559,11 @@ class timesheet_bo extends so_sql_cf $union_order[] = 'is_sum_'.$type; $sum_extra_cols[$type]{0} = '1'; // the $type sum - parent::search($criteria,$sum_ts_id[$type].",'','','',MIN(ts_start),SUM(ts_duration) AS ts_duration,". - ($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0').",0,NULL,0,0,0,0,0,SUM($total_sql) AS ts_total", - 'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); + parent::search($criteria,array( + $sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration', + ($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'), + '0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total" + ),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); $sum_extra_cols[$type]{0} = '0'; } $union_order[] = 'ts_start '.$sort;