- Issue created by @jaguero
A) TypeError: views_aggregator_average(): Argument #3 ($precision_group) must be of type ?int, string given, called in /***/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php on line 559 in views_aggregator_average() (line 180 of /***/web/modules/contrib/views_aggregator/views_aggregator_functions.inc).
B) TypeError: number_format(): Argument #1 ($num) must be of type float, string given in number_format() (line 867 of /***/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php).
1) Create a view with display of views aggregation table
2) add a custom field
3) adjust the table settings for the field by setting column/group aggregation to "average" and parameter = 2
index 605bcba9b..97e2e4d0e 100644
--- a/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php
+++ b/web/modules/contrib/views_aggregator/src/Plugin/views/style/Table.php
@@ -864,7 +864,7 @@ protected function renderNewValue(FieldHandlerInterface $field_handler, ?int $ro
$custom_format = preg_match('/number_format\((.*)\)/', substr($custom_formula, $start_pos), $matches, PREG_OFFSET_CAPTURE);
$custom_delimiters = str_getcsv($matches[1][0], ',', "'");
// Check if arguments are set, otherwise use dot for default decimal.
- $rendered_values[] = number_format($new_value, (int) $custom_delimiters[0] ?? 0, $custom_delimiters[1] ?? '.', $custom_delimiters[2] ?? '');
+ $rendered_values[] = number_format((float) $new_value, (int) $custom_delimiters[0] ?? 0, $custom_delimiters[1] ?? '.', $custom_delimiters[2] ?? '');
}
else {
$rendered_values[] = $new_value;
diff --git a/web/modules/contrib/views_aggregator/views_aggregator_functions.inc b/web/modules/contrib/views_aggregator/views_aggregator_functions.inc
index 54bdf2263..43ee758e5 100644
--- a/web/modules/contrib/views_aggregator/views_aggregator_functions.inc
+++ b/web/modules/contrib/views_aggregator/views_aggregator_functions.inc
@@ -177,10 +177,12 @@ function views_aggregator_group_and_compress(array $view_results, FieldHandlerIn
* @return array
* An array of values, one for each group and one for the column.
*/
-function views_aggregator_average(array $groups, FieldHandlerInterface $field_handler, ?int $precision_group, ?int $precision_column): array {
+function views_aggregator_average(array $groups, FieldHandlerInterface $field_handler, ?string $precision_group, ?string $precision_column): array {
$values = [];
$sum_column = 0.0;
$count_column = 0;
+ $precision_group = (int) $precision_group;
Change the input arguments for views_aggregator_average from ?int to ?string and cast them to int in the function. This adjustment matches the pattern of the other aggregator functions that are called from Table::executeAggregationFunctions().
The secondary issue was with the number_format function requiring a float value, which I applied a temporary fix and I haven't found what was changed to make $new_value no longer valid
Active
2.1
Code