Page MenuHomePhabricator

Add watchlist labels to meta=userinfo API
Closed, ResolvedPublicFeature

Description

A user's watchlist labels should be included in the action=query&meta=userinfo&uiprop=* API response, which is linked from Special:Preferences.


Derived Requirement

Include a user’s watchlist labels in the API response for
action=query&meta=userinfo&uiprop=*.
When a user queries this endpoint, the response must contain a structured list of all watchlist labels associated with that user.

Test Steps

Test Case 1: Verify labels returned match the user’s actual watchlist labels

  1. Navigate to *Special:WatchlistLabels*.
  2. Note the list of existing watchlist labels.
  3. Run the API request: api.php?action=query&meta=userinfo&uiprop=*
  4. Compare the API response to the labels seen in the UI.
  5. ✅❓❌⬜ AC1: Confirm that the labels returned in the API match exactly the labels associated with the user.

Test Case 2: Verify API response updates after adding a label

  1. Create a new label in *Special:WatchlistLabels*.
  2. Re-run the API request.
  3. ✅❓❌⬜ AC2: Confirm the newly added label appears in the API response.

Test Case 3: Verify API response updates after deleting a label

  1. Delete any existing label from *Special:WatchlistLabels*.
  2. Re-run the API request.
  3. ✅❓❌⬜ AC3: Confirm the deleted label no longer appears in the API response.

QA Results - Beta

ACStatusDetails
1T409375#11453215
2T409375#11453215
3T409375#11453215

Details

Related Changes in Gerrit:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1215117 had a related patch set uploaded (by Samtar; author: Samtar):

[mediawiki/core@master] ApiQueryUserInfo: Add `watchlistlabels`

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

At the moment, I have just the label names being returned via

$wl = [];
foreach ( $labels as $label ) {
    $wl[] = $label->getName();
}

giving:

{
  "batchcomplete": true,
  "query": {
    "userinfo": {
      "id": 1,
      "name": "Admin",
      "watchlistlabels": [
        "fox",
        "label1",
        "label2",
        "label3",
        "label4"
      ]
    }
  },

Is that enough, or do we want ID/count etc.?

I think adding the ID might be worthwhile, because in T409376 we want to also include the watchlist items, and presumably we'll include the labels (and expiries) with those, and it'd be easier to include the IDs there rather than the full names. But I don't really know how we're going to solve that task, so perhaps for now names only is fine.

Change #1215117 merged by jenkins-bot:

[mediawiki/core@master] ApiQueryUserInfo: Add `watchlistlabels`

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

@TheresNoTime Confirmed that watchlist labels was added to meta=userinfo API, as seen in the videos below. I will mark this as Resolved. Thanks for all your work!

Test Result - Beta

Status: ✅ PASS
Environment: Beta
OS: macOS Tahoe 26.1
Browser: Chrome 142
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Verify labels returned match the user’s actual watchlist labels

  1. Navigate to *Special:WatchlistLabels*.
  2. Note the list of existing watchlist labels.
  3. Run the API request: api.php?action=query&meta=userinfo&uiprop=*
  4. Compare the API response to the labels seen in the UI.
  5. ✅ AC1: Confirm that the labels returned in the API match exactly the labels associated with the user.

Test Case 2: Verify API response updates after adding a label

  1. Create a new label in *Special:WatchlistLabels*.
  2. Re-run the API request.
  3. ✅ AC2: Confirm the newly added label appears in the API response.

Test Case 3: Verify API response updates after deleting a label

  1. Delete any existing label from *Special:WatchlistLabels*.
  2. Re-run the API request.
  3. ✅AC3: Confirm the deleted label no longer appears in the API response.

GMikesell-WMF updated the task description. (Show Details)