Add services and utilities for automatic creation of temporary user
accounts on page save, in order to avoid exposing the user's IP
address.
* Add $wgAutoCreateTempUser, for configuring the system
* Add TempUserConfig service, which interprets the config.
* Add TempUserCreator service, which creates users during page save as
requested by EditPage. With proxy methods to TempUserConfig for
convenience.
* Add table user_autocreate_serial. Table creation is necessary before
the feature is enabled but is not necessary before deployment of this
commit.
Bug: T300263
Change-Id: Ib14a352490fc42039106523118e8d021844e3dfb
When newAnonymous() was called with a specified IP address, it called
newFromName(), leading to a DB query on User::load() as if the IP
address could be in the database.
Instead, use User::setName() which is documented to work for this
purpose and indeed appears to do so.
Change-Id: I8e8be719c89b1d1e4ae2cf9063db68b929bb3651
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together
Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
Originally was used as just a wrapper for the User class constructors,
but that has not been the case for a while.
Change-Id: I34027b36edab68ed71921da8443f22c7020cd334
Swap if/else branches, because the old else branch throws and than no
explicit else is needed in the new code.
Also avoid the local variable
Typehint newAnonymous, because the called UserNameUtils::isIp and
self::newFromName are also type hinted and needs a safe value
Change-Id: I2340cc1a49c12ff07f6e38dfbb3937032ff68deb
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.
Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
We started to call Authority argument $performer everywhere,
and $performer->getPerformer() doesn't look that good.
Change-Id: Id2cf3f27b18340314e4ed1ea9931ad9404b4df6f
* Convert everything that is protected to be private,
since the class is not stable to extend
* Remove PasswordReset::$hookContainer, unneeded
Additionally, add missing UserFactory::newFromRow,
for now just a wrapper for User::newFromRow
Bug: T253432
Change-Id: I1de57a08605ff6e0d2be8e276b7fcb08934fb5da
- Begin injecting services into UserDef to support
unit tests.
- Replace static User class functions with
UserFactory functions.
Bug: T259145
Bug: T257464
Change-Id: Iccc0c39e013679f15f2e62738c56df09ba56c494
Create a method in UserFactory to instantiate an anonymous
user with an optional IP address.
Bug: T257464
Change-Id: I557620f9bcd4b646288b4a76b26c4730fccbc3d8
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
Makes it possible to mock static User methods in tests;
actually introducing dependency injection to the User class is left for
the future.
New class has 100% code coverage
Bug: T253432
Change-Id: I0b93da09124d95beafd84e932b214909ce920230