Problem/Motivation
When a poll is configured to allow to view the results before voting, on the poll form a button "View results" disappear.
When going to the poll results as anonymous user (when the poll accepts anonymous votes), a button called "View poll" appears.
But when going to the poll as authenticated user, there is no "View poll" button.
I found out that this bug was introduced in #2944773: View poll button.
Additionally, there is a PHP notice when an authenticated user goes to the poll results before voting, but that's a different bug. And that one only occurs on later PHP versions, so it seems. I shall create a separate issue for this.
I noticed this issue while working on #3178162: Serialization error when switching between poll form and poll results as an anonymous user on PHP 7.4 and there it causes the tests to be less consistent.
Steps to reproduce
- Create a poll that allows to view the results before voting.
- As an authenticated user, go to the poll. The poll form gets displayed.
- Click the "View results" button. The poll vote results get displayed.
There is no "View poll" button, while there is one when accessing the poll as anonymous user.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
A patch with tests will follow. The posted test is similar to the one posted in #3178162: Serialization error when switching between poll form and poll results as an anonymous user on PHP 7.4.
Comment | File | Size | Author |
---|
Issue fork poll-3178172
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedThis is the tests only patch, I also plan to work on a fix, though that one will be borrowing code from #2909811: Anonymous users - Multiple voting from one IP.
Comment #3
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedI think that this patch will fix the issue.
Comment #4
Berdirthis is/was a really weird switch statement anyway and you just removed most cases. The $account variable is also unused now. Lets simplify to just a single return show results || isVotingAllowed?
Needs a reroll now anyway because the test conflicts.
Comment #5
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedHere is a reroll + the following changes:
PollViewForm::showResults()
is simplified, following the suggestion from #4.PollViewForm::showResults()
.PollVoteTest::testViewPollAndPollResultsAsAuthenticatedUser()
. See https://www.drupal.org/node/3168858.Comment #6
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedAlso adding an interdiff.
Comment #7
Berdirthe changes to test seem incomplete aka are only the interdiff in all versions of the patch.
Comment #8
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedNot sure why the patches didn't apply. I try with issue branches instead now...
Comment #11
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedHiding the patches.
Comment #12
askibinski CreditAttribution: askibinski as a volunteer commentedMR works as expected, button now appears on results page and works with ajax.
Created a patch based on the latest MR for those that prefer such.
Comment #14
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedBetter hide the patch as it can confuse the testbot. I also triggered a retest for the MR to check if test failures are also in there.
Comment #15
mpauloIs this still reproducible?
Comment #17
ivnish CreditAttribution: ivnish commented@BramDriesen is this already fixed in #3426799: Back to poll button only appears when allow anonymous vote is enabled ?
Comment #18
BramDriesenPartially yes. This seems to simplify some other things as well. Will backport those relevant changes to 2.0.x
Comment #23
BramDriesenCommitted the relevant changes to 2.0.x. Thanks all! The test coverage was increased for this in #3426799: Back to poll button only appears when allow anonymous vote is enabled
Comment #24
BramDriesen