From 27ebeffad41e39dda80159bc27605f5f247174c9 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 22 Dec 2021 09:50:50 +0000 Subject: update_poll() can be called many times in a row for the same item if a multiple poll is being updated. This could result in the queueworker not processing duplicates. We are now adding the source item mid to the notifier call as the third argument (fragment) so that the queueworker will not think they are duplicates. The fragment is also passed to the deliver_hooks call in the notifier --- include/text.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 84f112802..0522dd3c9 100644 --- a/include/text.php +++ b/include/text.php @@ -1872,6 +1872,13 @@ function format_poll($item,$s,$opts) { $output .= '
'; } if (array_key_exists('anyOf',$act) && is_array($act['anyOf'])) { + $totalResponses = 0; + foreach ($act['anyOf'] as $poll) { + if (array_path_exists('replies/totalItems',$poll)) { + $totalResponses += intval($poll['replies']['totalItems']); + } + } + foreach ($act['anyOf'] as $poll) { if (array_key_exists('name',$poll) && $poll['name']) { $text = html2plain(purify_html($poll['name']),256); @@ -1882,10 +1889,23 @@ function format_poll($item,$s,$opts) { $total = 0; } if ($activated && $commentable) { - $output .= ' ' . $text . '' . ' (' . $total . ')' . EOL; + //$output .= ' ' . $text . '' . ' (' . $total . ')' . EOL; + + $output .= '  ' . $text . '' . EOL; + $output .= '
'; + $output .= '
'; + $output .= '
'; + $output .= '
' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . ' | ' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '
'; + $output .= EOL; } else { - $output .= '[ ] ' . $text . ' (' . $total . ')' . EOL; + //$output .= '[ ] ' . $text . ' (' . $total . ')' . EOL; + $output .= '  ' . $text . '' . EOL; + $output .= '
'; + $output .= '
'; + $output .= '
'; + $output .= '
' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . ' | ' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '
'; + $output .= EOL; } } } -- cgit v1.2.3