Problem/Motivation

If you have multiple polls and for each of them you have at least one vote, then if you (manually) cancel all votes and go back to the polls list page, you will still see that for each poll at the 'total votes' column there are still votes stored. After doing a 'drush cr' and refreshing the page, the UI is properly updated.

Proposed resolution

- figure out where we update the UI
- why it's working properly
- fix it

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tduong created an issue. See original summary.

Berdir’s picture

Issue tags: +Needs tests

Nice catch.

We need a way to invalidate that overview without invalidating the the whole poll all the time.

We should introduce a new cache tag, like poll-votes:ID. In the views plugin that outputs it, make sure that cache tag is set on the response. When a vote is stored, invalidate that cache tag.

Start with a failing test.

tduong’s picture

Status: Active » Needs review

It seems like this bug has been fixed somehow in the meantime, but not sure if it is useful to have that cache tag anyway. What do you think ?

tduong’s picture

Discussed with @Berdir, the problem was that per default the "Poll admin" view has "Caching" set to "None", that is why it seemed like it worked fine. Setting it to "Tag based" + having $settings['cache']['bins']['render'] and $settings['cache']['bins']['dynamic_page_cache'] commented (= active caching) in settings.local.php, then the bug appears again.

Here the starting fix, but now I see that (giving permissions for anonymous votes) the anonymous choice is saved, but not for the admin...
And still needs a test.

tduong’s picture

Added test checking for the total votes render. Odd, in the "test UI" it renders the total votes correctly, but if we check it through the xpath $field_status it is not updated (like the bug reported in the issue).

The last submitted patch, 5: total_votes_ui_not_updated-2683393-5-test_only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: total_votes_ui_not_updated-2683393-5.patch, failed testing.

Berdir’s picture

The only thing wrong was the test :) You asserted with the old xpath element from the previous page.

I do like using xpath directly more though, but we can do a much more specific xpath expression for it, using the classes on the td.

Also extend the tests to cover vote cancel as well.

  • Berdir committed 5d1a05c on 8.x-1.x
    Issue #2683393 by tduong, Berdir: "Total votes" UI not properly updated
    
Berdir’s picture

Status: Needs review » Fixed
tduong’s picture

Oh gosh, so dumb... I guess I was too used to the test failing "randomly" lately and haven't thought about that... my bad! ^^'
Thanks :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.