humanmade / comment-popularity

Allow visitors to vote on comments
MIT License
25 stars 15 forks source link

Prevent downvoting zero karma comment #115

Closed pdewouters closed 6 years ago

slavicd commented 6 years ago

I do not think this works as intended: vote value should be the reverse of last action, rather than zero for undo votes.

pdewouters commented 6 years ago

When a visitor attempts to downvote a comment that has zero karma, it will simply log an error and return early: https://github.com/humanmade/comment-popularity/pull/115/files#diff-3a9980997cb73c1df4eb4b6fd05d169eR661

I added the case for undo just to avoid returning a WP_Error from the default case in the switch statement