Page MenuHomePhabricator

Cannot correctly favourite or unfavourite more than one template at a time
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

In the Insert template dialog, if I favourite or unfavourite more than one template, only the last template that you (un)favourited will actually be (un)favourited.

It seems to be related to the API request, which does not remember the ID of previously favourited templates in subsequent requests.

Moreover, the templates in the Favourites tab have an empty icon.

Steps to reproduce problem
  1. Login to https://en.wikipedia.beta.wmcloud.org
  2. Open any article and edit
  3. Open the Insert template dialog
  4. Either search for templates in the Search input or go to the Featured tab
  5. Favourite two or more templates
  6. Go to the Favourites tab and see the templates you favourited (although their favourite icon is empty)
  7. Refresh the page and open the Insert template dialog again
  8. See that only one template is in the Favourites tab

A similar thing happens if you unfavourite two or more templates, only the last template will be unfavourited.

Environment

Wiki(s): https://en.wikipedia.beta.wmflabs.org TemplateData 0.2.0 (8b2177c) 08:05, 14 August 2025.
Editor:

  • WikiEditor 0.5.4 (cb013fa) 08:06, 14 August 2025.
  • VisualEditor – (8c69980) 12:39, 14 August 2025.
Screenshots

Example of attempting to favourite two templates. Notice that the API request only has one ID each time, the ID of the first favourited template is not included in the second API request:

Event Timeline

Change #1179026 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/TemplateData@master] Move save logic into FavoritesStore.save(), and add Selenium tests

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

Change #1179647 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/TemplateData@master] Move favorites' save logic into FavoritesStore.saveFavoritesArray()

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

Samwilson changed the task status from Open to In Progress.Aug 18 2025, 11:32 PM

Change #1179647 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Move favorites' save logic into FavoritesStore.saveFavoritesArray()

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

Change #1179026 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Fix favoritesArray cloning in FavoritesStore, and add Selenium tests

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

@Samwilson I find if I favourite or unfavourite multiple templates in quick succession, the end state of favourited templates is not always correct. It seems like a race-condition, where the templatedata-favorite-templates list in the API request can include IDs of templates which had been removed in previous requests, or not include IDs which had been added in previous requests.

Change #1190003 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/TemplateData@master] Save FavoritesStore.favoritesArray before saving user option

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

Change #1190003 merged by jenkins-bot:

[mediawiki/extensions/TemplateData@master] Save FavoritesStore.favoritesArray before saving user option

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

It looks like this is working correctly now. Closing without QA, to try to clear up the old tasks.