Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#8 | total_votes_ui_not_updated-2683393-8-interdiff.txt | 1.25 KB | Berdir |
#8 | total_votes_ui_not_updated-2683393-8.patch | 6.04 KB | Berdir |
| |||
#5 | total_votes_ui_not_updated-2683393-5.patch | 5.68 KB | tduong |
#5 | total_votes_ui_not_updated-2683393-5-test_only.patch | 1.4 KB | tduong |
#5 | interdiff-2683393-4-5.txt | 1.77 KB | tduong |
Comments
Comment #2
BerdirNice 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.
Comment #3
tduong CreditAttribution: tduong at MD Systems GmbH commentedIt 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 ?
Comment #4
tduong CreditAttribution: tduong at MD Systems GmbH commentedDiscussed 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.
Comment #5
tduong CreditAttribution: tduong at MD Systems GmbH commentedAdded 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).
Comment #8
BerdirThe 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.
Comment #10
BerdirComment #11
tduong CreditAttribution: tduong at MD Systems GmbH commentedOh gosh, so dumb... I guess I was too used to the test failing "randomly" lately and haven't thought about that... my bad! ^^'
Thanks :)