Page MenuHomePhabricator

UserFactory::newFromName should handle no validation
Closed, ResolvedPublic

Description

When UserFactory was introduced in T253432, a change was made to the signature of newFromName. User::newFromName accepts string|bool for the $validation param, but UserFactory::newFromName casts it to a string.

If User::newFromName is called with $validate = false, then User::getCanonicalName picks a default validation strategy: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/changes/44/598144/6/includes/user/User.php#1135

But if false is passed to UserFactory::newFromName, it is cast to empty string, so it fails the above check and is never set to a valid strategy. An error is then thrown in UserNameUtils::getCanonical: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/changes/44/598144/6/includes/user/UserNameUtils.php#300

Related Objects

Event Timeline

Change 606007 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/core@master] UserFactory: Allow no validation with UserFactory::newFromName

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

Change 606007 merged by jenkins-bot:
[mediawiki/core@master] UserFactory: Document that newFromName expects a validation constant

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

DannyS712 assigned this task to Tchanders.