Fix admin username underscore#92
Open
Ishta-P-Jain wants to merge 6 commits into
Open
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
reviewed
Jul 4, 2026
samwilson
left a comment
Member
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>
Author
|
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? |
Member
|
Thanks! Looks good. I'm attempting to fix the CI failure: wikisource/api#19 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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