Commit graph

13 commits

Author SHA1 Message Date
Derick Alangi
f88eab53a6 tests: Use overrideConfig(Value|Values) where needed
This continues the work in the child patch to replace callers
of setMwGlobals() with the appropriate method. Directory this
patch covers is `tests/phpunit/integration/`.

Change-Id: I0a9abf0d2a43587f2ffa029b68024a1ba5165fc7
2022-07-12 14:40:46 +01:00
Tim Starling
e8dbf5f80c TempUser infrastructure and services
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
2022-04-14 09:23:55 +10:00
Tim Starling
1b0b40016c Fix UserFactory::newAnonymous() performance
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
2022-03-30 17:31:38 +11:00
Reedy
6e29611642 Remove or replace usages of "sanity"
Still some more to go...

Bug: T254646
Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
2021-11-21 16:42:31 +00:00
Derick Alangi
e894dc75fa tests: Use service container in integration tests cases
Since MediaWiki 1.36, this method is provisioned to replace creating
new instances of the services object. If one is already created and
seen by the service locator, just use it.

Change-Id: I9509497a8380194aa93310343b1896521070fc31
2021-09-05 22:14:36 +01:00
daniel
fed7f0b179 Remove $actor field from UsererIdentityValue
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.

Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.

Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
2021-04-13 18:18:06 +00:00
daniel
4dce6dd0c3 Deprecate UserIdentity::getActorId()
Note: User::getActorId() is not (yet) deprecated.

Bug: T274179
Change-Id: Ic2ca6d489db821fc2334e53bf2496c7b0d3ea5b1
2021-03-13 19:45:57 +01:00
daniel
7e2f7efa27 Convert Language to UserIdentity
This also introduces minimal instance caching into UserFactory

Change-Id: I594c5668c537477516dda4beecd11b8aa840ae62
2021-03-11 20:23:23 +01:00
Petr Pchelko
30cf40568b Add Authority to Context
Bug: T271460
Change-Id: If1038c94ccf8f3e59b5242f5c33b66f076c60816
2021-01-20 09:07:27 -06:00
DannyS712
e9c0f8236c Migrate more User::newFrom* methods to UserFactory
Bug: T253432
Depends-On: If5e76f2ae570ef4ae58cb77b5281c4446a1cadff
Change-Id: I9286d4a69911a84661cba40c55c0a4e3f1b7f7f3
2020-10-05 23:47:53 +00:00
DannyS712
4db93b3be4 Inject dependencies into PasswordReset, and cleanup
* 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
2020-10-03 00:23:59 +00:00
Nikki Nikkhoui
6c8187d4f8 UserFactory method for getting anonymous user
Create a method in UserFactory to instantiate an anonymous
user with an optional IP address.

Bug: T257464
Change-Id: I557620f9bcd4b646288b4a76b26c4730fccbc3d8
2020-07-15 00:07:45 +00:00
DannyS712
61a3a8f734 UserFactory v.1 - wrapper for User::newFrom* static methods
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
2020-06-10 20:38:26 -07:00