Page MenuHomePhabricator

Add API module for voting to allow users to update or remove their votes
Closed, ResolvedPublic8 Estimated Story Points

Description

// This fixes a bunch of bugs within the voting functionality, let's go back to it when we look at bugs.

Problem
  • After voting on a wish, there's no easy way to remove your vote or modify the comment (T399500)
  • If a comment contains unbalanced wikitext, it can break display of the entire voting section (T404000)
  • Users don't know that they need to go to a /Votes page to modify or remove votes, and even if they do, the syntax is not very straightforward to work with.
Proposal

Let's do like we've done for entity pages and treat the /Votes page as a pseudo-structured page managed only by the backend (or those with the manually-edit-wishlist user right).

We already have the ArgumentExtractor class that can turn wikitext using our parser functions into structured data. The only piece missing for this work for voting is to iterate over the /Votes page and feed each line into the ArgumentExtractor.

Doing this will solve the three problems above, since we can validate that the wikitext has no unbalanced tags or template syntax, and we'll be able to easily change or remove an existing vote.

We tie all this together in a new API module, ApiWishlistVote (or whatever), that works like the other ApiWishlistEntityBase subclasses by internally making an action=edit request. Then we can prevent manual editing of the /Votes page altogether.

Finally, the voting Vue app would need to be changed to use our API instead of editing the /Votes page directly. Also, the responsibility of purging the entity page can be moved to the backend, cleaning up the code a bit in the Vue app.

Drawbacks

  • We possibly won't be able to allow for comments anymore, at least not easily.
    • We don't want a situation where a DiscussionTools comment breaks things, and users have to ask a Community Wishlist manager to fix it.
  • … ?
Acceptance criteria
  • A new action=wishlistvote endpoint should be available that takes an entity (i.e. W1, FA4), a comment, and an action (either add or remove). QA efforts can be done solely using the voting button; There is no need to test the API directly.
  • After placing a vote on a wish or focus area, a message like "You've already voted" should be shown, with buttons to edit the comment or remove the vote
  • Any updates to the /Votes page via the voting button and dialog should be visible immediately (i.e. you shouldn't have to manually run action=purge on the page)
  • An error should be shown when attempting to submit a vote with unbalanced wikitext (Example: This is my comment }}, or stray pipes like This | is my comment)

Event Timeline

KSiebert set the point value for this task to 5.Sep 18 2025, 1:44 PM
MusikAnimal changed the point value for this task from 5 to 8.Sep 19 2025, 5:50 AM

Change #1189627 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CommunityRequests@master] ApiWishlistVote: new API module for voting on wishlist entities

https://gerrit.wikimedia.org/r/1189627

MusikAnimal changed the task status from Open to In Progress.Sep 24 2025, 9:10 PM
MusikAnimal renamed this task from Adding API module for voting to Add API module for voting to allow users to update or remove their votes.Sep 26 2025, 9:38 PM
MusikAnimal updated the task description. (Show Details)

Change #1189627 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] ApiWishlistVote: new API module for voting on wishlist entities

https://gerrit.wikimedia.org/r/1189627

MusikAnimal changed the task status from In Progress to Open.Oct 14 2025, 6:57 AM
dom_walden subscribed.

I wrote a script to vote on all the wishes on https://meta.wikimedia.beta.wmcloud.org/wiki/Community_Wishlist as 10 different users, edit the comments on those votes and then remove my votes.

I checked that votes were added, updated and removed correctly from Community_Wishlist/<id>/Votes.

I briefly tested adding and removing votes as two different users concurrently. One user always got a response {'error': {'code': 'editconflict', 'info': 'Edit conflict.' ... after which I guess they can just retry.

I when you include disallowed wikitext in the comment you get the validation error Unable to parse wishlist vote. It may contain invalid wikitext. Please ensure there are no extraneous pipe characters ("|") in the wikitext. This could be improved as pipe characters are not the only wikitext we disallow.

I did find T407193.