Closed (fixed)
Project:
Poll
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2019 at 15:47 UTC
Updated:
12 Dec 2019 at 20:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
idebr commentedAttached patch adds the current user's vote to the poll-results.html.twig
I will try to add some test coverage at a later time.
Comment #3
berdirIt is also called in template_preprocess_poll_meter() now, can we update that to avoid calling the results multiple times? I only just now realized that the other one does call it for each option, which is not optimal :-/ Alternatively, there's a separate issue to add static caching to that method, that would be fine too then.
Comment #4
idebr commented#3 Lendude is implementing static caching in #3094531: Statically cache PollVoteStorage::getUserVote().
Attached patch adds test coverage.
Comment #5
idebr commentedFixed the
@groupannotation to the correct project.Comment #6
lendudeThink we need to wait for 8.6 to go unsupported before we can
??Comment #7
berdiris 7 the same as the functional test? seems a bit overkill especially since we're not ever going to bother with testing how it looks in the UI or so, so maybe default to 2 or 3 options?
relying on the current user in a kernel test is a bit strange, can't we just pass in a user id? then we can skip the current user set up in the test.
$poll->get('choice')->target_id is the same and short enough to be inlined with the saveVote() call IMHO.
Relying on __get() isn't great, but on the field level, there is no good alternative right now, we specifically optimized that, compared to getValue(), which is awkward to use and get('target_id')->getValue(), which has to create another object.
Comment #8
idebr commented#6 Restored the
isset()implementation for backwards compatibility.#7.1 7 choices matches the functional test. I reduced the default number to 2 for now.
#7.2 Removed the current user setup from the Kernel test
#7.3 Updated the code calling the choice target id to use
$poll->get('choice')->target_idComment #9
lendudeAll feedback addressed, looks good!
Comment #11
berdirYes, looks good. I realized in the other issue that poll vote storage does rely on the current user, so setting it up like that in general makes sense, but it defaults to 0, so we don't need it for that.
Committed.