From 14bb09fe7fe2b18953fb5d9f2957028672fcf7ce Mon Sep 17 00:00:00 2001 From: Thalia Date: Tue, 16 Jun 2020 21:26:53 +0100 Subject: [PATCH] UserFactory: Document that newFromName expects a validation constant When no validation is wanted, a UserNameUtils constant must be passed to UserFactory::newFromName, whereas User::newFromName accepts false. Also pass a constant as the default parameter, rather than the string value of that constant. Bug: T255611 Change-Id: Iffd405cb8b38debe9d0a7106a76c430956351583 --- includes/user/UserFactory.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/user/UserFactory.php b/includes/user/UserFactory.php index 6399be1998b..2990e67488a 100644 --- a/includes/user/UserFactory.php +++ b/includes/user/UserFactory.php @@ -38,10 +38,14 @@ class UserFactory implements IDBAccessObject { /** * @see User::newFromName * @param string $name - * @param string $validate + * @param string $validate Validation strategy, one of the UserNameUtils::RIGOR_* + * constants. For no validation, use UserNameUtils::RIGOR_NONE. * @return User|bool */ - public function newFromName( string $name, string $validate = 'valid' ) { + public function newFromName( + string $name, + string $validate = UserNameUtils::RIGOR_VALID + ) { return User::newFromName( $name, $validate ); }