diff --git a/.upgradenotes/MDL-52046-2024061805141748.yml b/.upgradenotes/MDL-52046-2024061805141748.yml new file mode 100644 index 0000000000000..4e0600dacced7 --- /dev/null +++ b/.upgradenotes/MDL-52046-2024061805141748.yml @@ -0,0 +1,8 @@ +issueNumber: MDL-52046 +notes: + core_reportbuilder: + - message: >- + The return type of the `set_checkbox_toggleall` callback, defined by + system reports, can now be null. Use if the checkbox should not be shown + for the row. + type: improved diff --git a/reportbuilder/classes/system_report.php b/reportbuilder/classes/system_report.php index 07003c957b067..db859b9890292 100644 --- a/reportbuilder/classes/system_report.php +++ b/reportbuilder/classes/system_report.php @@ -143,7 +143,7 @@ final public function get_base_fields(): array { * Define toggle all checkbox for the report, required row data should be defined by calling {@see add_base_fields} * * @param callable $callback Callback to return value/label for each checkbox, implementing the following signature: - * function(stdClass $row): array containing value/label pair + * function(stdClass $row): ?array containing value/label pair, or null if the checkbox should not be shown for the row */ final protected function set_checkbox_toggleall(callable $callback): void { $this->checkboxcallback = $callback; @@ -166,7 +166,11 @@ final public function get_checkbox_toggleall(bool $ismaster, ?stdClass $row = nu $value = ''; $label = get_string('selectall'); } else { - [$value, $label] = ($this->checkboxcallback)($row); + $checkboxdata = ($this->checkboxcallback)($row); + if ($checkboxdata === null) { + return null; + } + [$value, $label] = $checkboxdata; } return new checkbox_toggleall('report-select-all', $ismaster, [