From b73a69b920ecabf451f9a44334fb7e47ce774d98 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 11 Mar 2022 11:12:40 +0000 Subject: [PATCH] MDL-74175 cohort: correct type/callback of entity category column. --- cohort/classes/local/entities/cohort.php | 6 +++--- reportbuilder/classes/local/report/column.php | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cohort/classes/local/entities/cohort.php b/cohort/classes/local/entities/cohort.php index 992a9761eb2..8a01ded522f 100644 --- a/cohort/classes/local/entities/cohort.php +++ b/cohort/classes/local/entities/cohort.php @@ -94,11 +94,11 @@ class cohort extends base { $this->get_entity_name() )) ->add_joins($this->get_joins()) - ->set_type(column::TYPE_INTEGER) + ->set_type(column::TYPE_TEXT) ->add_fields("{$tablealias}.contextid") ->set_is_sortable(true) - ->add_callback(static function(int $contextid): string { - return context::instance_by_id($contextid)->get_context_name(false); + ->add_callback(static function($contextid): string { + return context::instance_by_id((int) $contextid)->get_context_name(false); }); // Name column. diff --git a/reportbuilder/classes/local/report/column.php b/reportbuilder/classes/local/report/column.php index 0722aadf7c4..d0177c3e4e6 100644 --- a/reportbuilder/classes/local/report/column.php +++ b/reportbuilder/classes/local/report/column.php @@ -478,7 +478,9 @@ final class column { * The callback should implement the following signature (where $value is the first column field, $row is all column * fields, and $additionalarguments are those passed on from this method): * - * The type of the $value parameter passed to the callback is determined by calling {@see set_type} + * The type of the $value parameter passed to the callback is determined by calling {@see set_type}, however note that + * if the column is part of a report source and can be aggregated using one of the "Group concatenation" methods then the + * type should be omitted if it's not string * * function($value, stdClass $row[, $additionalarguments]): string *