On /poll page the number of votes are incorrect.
How to reproduce:

  1. Enable poll module for the first time
  2. Create a simple poll, 2 answers 0 starting vote counts (with uid 1)
  3. Vote for this poll (with uid 1)
  4. Add permission for anonymous users to see poll results
  5. Check the /poll page with uid 1. It will show 1 vote for the poll.
  6. Check the /poll page with anonymous. It will show 2 votes for the poll.

Core: Drupal 7.12

In the recent poll block it shows "1 vote", the correct number of votes!

Comments

edgarpe’s picture

Project: Drupal core » Poll
Issue summary: View changes

Added core version info.

amateescu’s picture

Project: Poll » Drupal core
Version: 7.x-dev » 8.x-dev
Status: Active » Postponed (maintainer needs more info)

I cannot reproduce this in D7 latest -dev or D8. Are you sure these are only steps to reproduce the problem? Can you also try on a fresh Drupal install?

edgarpe’s picture

I'll try it with 7.x-dev or newer 7.14 and report what I found.

alexpott’s picture

Project: Drupal core » Poll
Version: 8.x-dev » 8.x-1.x-dev
Component: poll.module » Code

Poll is no longer part of core

adammalone’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Can't reproduce this on a fresh 8.x install using instructions in #0

Feel free to open the issue again if it can be reproduced.

adammalone’s picture

Issue summary: View changes

Added more info about the recent poll block.

JensH’s picture

Issue summary: View changes
Status: Closed (cannot reproduce) » Active

This is not the same problem as the one from OP, but I think there is an issue with the translation in the PollViewForm::showPollResults():

      $display_votes = (!$block) ? ' (' . \Drupal::translation()
          ->formatPlural($vote, '1 vote', '@count votes') . ')' : '';

This will show "0% (1 vote)" for each answer on the result page of the poll when no user voted yet. It should be "0% (0 vote)", so the formatPlural() should depend on the votes.

JensH’s picture

StatusFileSize
new705 bytes

Patch included

martijn de wit’s picture

Status: Active » Needs review

Changing status because there is an actual patch now.

----

Using patch and fixes problem

berdir’s picture

0 should use the plural version, what language are you using if you get that problem? maybe an issue with the plural formula? the current approach matches the documentation and while these do often not cover 0, that should work, I certainly can't reproduce this problem.

The dynamic string also means that detection of translatable strings doesn't work.

pbouchereau’s picture

The problem comes from the fact that 0 isn't considered plural in all languages.
I think that the translation system handles that well, except when the count is hardcoded.
Is there a reason not to use the available placeholder for the singular form?

Wouldn't this work?

\Drupal::translation()->formatPlural($vote, '@count vote', '@count votes')

pbouchereau’s picture

StatusFileSize
new723 bytes

Here's a simpler patch that fixes the issue for me in French.
This one doesn't get in the way of translatable strings detection.

It's not related to the issue described here though, as pointed out in #5.
Should we open a new issue for this?

bramdriesen’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Closed (outdated)
StatusFileSize
new30.18 KB

I tested this out but I think this is no longer an issue. Translations are properly being shown for me without the patch.

Feel free to re-open if I'm wrong.