What is the problem?
If you try to edit an existing label and change its name to be the same as another one of your labels, you get an exception:
Error 1062: Duplicate entry '15233-New Label Adam 1' for key 'wll_user_name'
Function: MediaWiki\Watchlist\WatchlistLabelStore::save
Query: UPDATE `watchlist_label` SET wll_name = 'New Label Adam 1' WHERE wll_id = 118
Backtrace:
from /var/www/html/w/includes/libs/Rdbms/Database/Database.php(1226)
#0 /var/www/html/w/includes/libs/Rdbms/Database/Database.php(1210): Wikimedia\Rdbms\Database->getQueryException()
#1 /var/www/html/w/includes/libs/Rdbms/Database/Database.php(1184): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()
#2 /var/www/html/w/includes/libs/Rdbms/Database/Database.php(641): Wikimedia\Rdbms\Database->reportQueryError()
#3 /var/www/html/w/includes/libs/Rdbms/Database/Database.php(1527): Wikimedia\Rdbms\Database->query()
#4 /var/www/html/w/includes/libs/Rdbms/Database/DBConnRef.php(127): Wikimedia\Rdbms\Database->update()
#5 /var/www/html/w/includes/libs/Rdbms/Database/DBConnRef.php(462): Wikimedia\Rdbms\DBConnRef->__call()
#6 /var/www/html/w/includes/libs/Rdbms/QueryBuilder/UpdateQueryBuilder.php(332): Wikimedia\Rdbms\DBConnRef->update()
#7 /var/www/html/w/includes/Watchlist/WatchlistLabelStore.php(34): Wikimedia\Rdbms\UpdateQueryBuilder->execute()
#8 /var/www/html/w/includes/Specials/SpecialWatchlistLabels.php(139): MediaWiki\Watchlist\WatchlistLabelStore->save()
#9 /var/www/html/w/includes/HTMLForm/HTMLForm.php(812): MediaWiki\Specials\SpecialWatchlistLabels->onSubmit()
#10 /var/www/html/w/includes/HTMLForm/HTMLForm.php(693): MediaWiki\HTMLForm\HTMLForm->trySubmit()
#11 /var/www/html/w/includes/HTMLForm/HTMLForm.php(709): MediaWiki\HTMLForm\HTMLForm->tryAuthorizedSubmit()
#12 /var/www/html/w/includes/Specials/SpecialWatchlistLabels.php(103): MediaWiki\HTMLForm\HTMLForm->show()
#13 /var/www/html/w/includes/Specials/SpecialWatchlistLabels.php(58): MediaWiki\Specials\SpecialWatchlistLabels->showForm()
#14 /var/www/html/w/includes/SpecialPage/SpecialPage.php(711): MediaWiki\Specials\SpecialWatchlistLabels->execute()
#15 /var/www/html/w/includes/SpecialPage/SpecialPageFactory.php(1743): MediaWiki\SpecialPage\SpecialPage->run()
#16 /var/www/html/w/includes/Actions/ActionEntryPoint.php(499): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#17 /var/www/html/w/includes/Actions/ActionEntryPoint.php(143): MediaWiki\Actions\ActionEntryPoint->performRequest()
#18 /var/www/html/w/includes/MediaWikiEntryPoint.php(184): MediaWiki\Actions\ActionEntryPoint->execute()
#19 /var/www/html/w/index.php(44): MediaWiki\MediaWikiEntryPoint->run()
#20 {main}Steps to reproduce problem
- On any local test environment, add this to LocalSettings.php: $wgEnableWatchlistLabels = true;
- Login
- Create two labels by going to Special:WatchlistLabels/edit
- On Special:Watchlist, click on the edit icon next to one of your labels
- Change the name to be the same as the other label
Expected behaviour: Some sort of validation warning saying you cannot create a duplicate label
Observed behaviour: Exception above
Environment
Wiki(s): local docker MediaWiki 1.46.0-alpha (66c0066) 07:36, 25 November 2025.
Derived Requirement
Prevent users from editing an existing watchlist label to a name that already exists for that user. When a duplicate label name is entered, display a validation warning instead of causing a database exception.
Test Artifact(s):
Test Steps
Test Case 1: Prevent Duplicate Watchlist Label Names on Edit
- On a local test environment, add $wgEnableWatchlistLabels = true; to LocalSettings.php and reload the wiki.
- Login as any registered user.
- Navigate to Special:WatchlistLabels/edit and create two distinct labels.
- Navigate to Special:Watchlist and click the edit icon next to one of your labels.
- Attempt to change the label name to match the name of the other label.
- ✅❓❌⬜ AC1: Confirm that the system prevents the duplicate label name from being saved.
- ✅❓❌⬜ AC2: Confirm that a validation warning is displayed, informing the user that a label with that name already exists.
QA Results - Local
| AC | Status | Details |
|---|---|---|
| 1 | ✅ | T411028#11434925 |
| 2 | ✅ | T411028#11434925 |