Page MenuHomePhabricator

SecurePoll: Duplicate input id for custom column labels
Closed, ResolvedPublic5 Estimated Story PointsBUG REPORT

Description

What is the problem?

When there are more than two questions, if you click Use custom messages for column labels for the 3rd question it will check the box for the 2nd question.

This is because the id attribute of the <input> element is the same for the 2nd and 3rd (or later) questions.

Steps to reproduce problem
  1. Go to Special:SecurePoll/create
  2. For "Poll Type", select one of the 4 "range" types
  3. Click the "Add another question" button twice
  4. In the very last (3rd) question, click the label (not the checkbox itself) which states "Use custom messages for column labels"

Expected behavior: The checkbox next to it is checked
Observed behavior: The checkbox for question 2 is checked

Environment

Browser: Firefox 78
Wiki(s): SecurePoll 2.0.0 (5c73aa8) 07:40, 11 February 2021.

Screenshots (if applicable):

label_checkbox.png (1×2 px, 119 KB)

Event Timeline

Niharika moved this task from Untriaged to Triage/To be Estimated on the Anti-Harassment board.

Change 664886 had a related patch set uploaded (by STran; owner: STran):
[mediawiki/core@master] Force unique ids for cloner-generated elements

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

Change 664886 merged by jenkins-bot:
[mediawiki/core@master] Force unique ids for cloner-generated elements

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

The bug in the description no longer occurs. I have verified that all the labels in the question input go to the right input when you click them.

I tried a number of different ways of interacting with the form (by adding and deleting questions and options), but couldn't generate any duplicate IDs.

We have a global counter that gets iterated each time a new cloner element is created, so ids are unique like ooui-php-61-clone1, ooui-php-61-clone2. The counter is iterated both for new questions and new options for existing questions.

Although we have not (in theory) changed anything relating to how the input gets saved, I did also test creating and editing elections and verifying everything looked ok in the database.

This change is part of core and "cloner" elements are used in a couple of other places:

  • The Voter Eligibility page (I briefly tested this also, although we might be getting rid of it soon)
  • https://www.mediawiki.org/wiki/Extension:GlobalWatchlist (This is still in beta, so did not test)
  • CentralAuth Special:GlobalUserMerge (This special page is disabled everywhere I believe, so did not test)

Test Environment: vote.wikimedia.beta.wmflabs.org (Sorry, I forgot to record the specific version)