Fix admin username underscore#92
Conversation
Usernames with underscores (e.g. Bennylin_(WMID)) were not being recognized as matching their space-separated form when checking contest admin permissions, so affected admins couldn't edit or delete their own contests. MediaWiki treats underscores and spaces in usernames as interchangeable, so this normalizes both sides of the comparison, and normalizes admin names on save. Bug: T336157
Companion fix to 0f3e7ed. hasAdmin() used a strict LIKE match between the stored admin name and the logged-in username, so admins saved with an underscore-separated name (before the previous fix) still couldn't edit their contests. Bug: T336157
samwilson
left a comment
There was a problem hiding this comment.
Looks good. A few suggestions. Also, there are some CI issues.
Co-authored-by: Sam Wilson <sam@samwilson.id.au>
|
Thanks for the review! I've addressed the suggested changes. I noticed the remaining CI failure is in IndexPageRepositoryTest with a 403 Forbidden response from the Wikidata Query Service. Is this an existing CI issue, or would you like me to investigate it further? |
|
Thanks! Looks good. I'm attempting to fix the CI failure: wikisource/api#19 |
@samwilson I had provided some minor suggestions in wikisource/api#19. Please have a look whenever youhave time and also went through the PR and i can confirm that it fixes the issue, but is there any reaosn it still hasn't been merged? |
|
@samwilson |
|
There are some more incompatibilities to resolve, sorry. I'm doing so now. |
|
Here: #93 (but there are issues, such as addshore/addwiki#242 ). |
|
@samwilson Please have a look at the above reviewed comments whenever you get time! |
Summary
MediaWiki treats underscores and spaces in usernames as
interchangeable, but wscontest was comparing them as plain strings
in several places:
ContestsController::edit()and::delete()compared admin nameswith strict
===.ContestRepository::hasAdmin()(which controls whether the Editbutton is shown at all) used an exact
LIKEmatch in SQL.ContestsController::save()stored whatever raw string was typedinto the admins textarea, underscore and all.
This PR normalizes underscores to spaces on both sides of every
admin-username comparison, and normalizes admin names before they're
saved, so the two forms of a username are always treated as
equivalent.
Testing
Manually verified locally that:
breaks their ability to edit the contest.
the database) can now also edit, thanks to the
hasAdmin()fix.Bug: T336157