Skip to content

Commit

Permalink
MDL-75358 blog: Make attachment callback parameter nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Oct 31, 2022
1 parent aaca32f commit 4caae7c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions blog/classes/reportbuilder/local/entities/blog.php
Expand Up @@ -140,7 +140,7 @@ protected function get_all_columns(): array {
->add_joins($this->get_joins())
->set_type(column::TYPE_BOOLEAN)
->add_fields("{$postalias}.attachment, {$postalias}.id")
->add_callback(static function(bool $attachment, stdClass $post): string {
->add_callback(static function(?bool $attachment, stdClass $post): string {
global $CFG, $PAGE;
require_once("{$CFG->dirroot}/blog/locallib.php");

Expand Down Expand Up @@ -172,14 +172,14 @@ protected function get_all_columns(): array {
->set_type(column::TYPE_TEXT)
->add_fields("{$postalias}.publishstate")
->set_is_sortable(true)
->add_callback(static function(string $publishstate): string {
->add_callback(static function(?string $publishstate): string {
$states = [
'draft' => new lang_string('publishtonoone', 'core_blog'),
'site' => new lang_string('publishtosite', 'core_blog'),
'public' => new lang_string('publishtoworld', 'core_blog'),
];

return (string) ($states[$publishstate] ?? $publishstate);
return (string) ($states[$publishstate] ?? $publishstate ?? '');
});

// Time created.
Expand Down

0 comments on commit 4caae7c

Please sign in to comment.