From eaf71f39ec80ad144655c8041a39ec8a3c147e12 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 11 Apr 2023 15:43:21 +0200 Subject: [PATCH] fix comments events pandora_enterprise#10631 --- pandora_console/include/functions_ui.php | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 11670b33f6..c4f030e5c9 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -7031,23 +7031,20 @@ function ui_print_comments($comments) } } - $last_comment = []; - foreach ($comments_array as $comm) { - // Show the comments more recent first. - if (is_array($comm)) { - $order_utimestamp = array_reduce( - $comm, - function ($carry, $item) { - $carry[$item['utimestamp']] = $item; - return $carry; - } - ); + $order_utimestamp = array_reduce( + $comments_array, + function ($carry, $item) { + foreach ($item as $k => $v) { + $carry[$v['utimestamp']] = $v; + } - $key_max_utimestamp = max(array_keys($order_utimestamp)); - - $last_comment = $order_utimestamp[$key_max_utimestamp]; + return $carry; } - } + ); + + $key_max_utimestamp = max(array_keys($order_utimestamp)); + + $last_comment = $order_utimestamp[$key_max_utimestamp]; if (empty($last_comment) === true) { return '';