Commit graph

228 commits

Author SHA1 Message Date
jenkins-bot
db4a5d4e71 Merge "Extract RateLimiter from User" 2022-06-28 06:19:17 +00:00
daniel
dd2e9905cd Extract RateLimiter from User
This moves the logic for rate limiting out of the User class into a
standalone service.

Change-Id: I2881913876c855a1538bac92f0dabac3b3bddcfc
2022-06-27 13:23:24 +00:00
Matěj Suchánek
857d9d80f9 Hard deprecate User::blockedFor
Deprecated since 1.35, unused in Wikimedia code.

Change-Id: I79eb801331f4ff7d02332b9aa7c085ac0564d9d5
2022-06-21 22:49:50 +02: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
daniel
e239b02a5e Add convenience methods for asserting status.
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.

Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
2022-03-16 22:44:25 +01:00
Tim Starling
b6c3bf46dc Fix User::getRealName() test
Make it do what the assertion message says

Change-Id: If63b8e664d0361a028cd1d47d614b475463b74cd
2022-03-08 20:02:14 +11:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
Umherirrender
977f0c0c19 Remove passing markTestSkippedIfDbType or add comment
It seems some tests are fixed in the meantime without removing the
skipped part for this.

Bug: T195807
Follow-Up: I58261dd70eea3581803987a4a7739c7d55558f42
Change-Id: Ie883b7056cdd0cb6bec81c2f7e4ed54177b4ecb2
2022-01-22 17:04:53 +00:00
Reedy
8c39aab84b Remove or replace usages of "sanity"
Bug: T254646
Change-Id: Ib192dc5704a14d02c7c374d0ab29bac55c5df24a
2021-11-21 19:35:49 +00: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
vladshapik
9d13a3cb5b Drop User methods which were deprecated since 1.36
The following User methods, deprecated in 1.36, have been removed:
- ::isLoggedIn,
- ::getFirstEditTimestamp,
- ::getLatestEditTimestamp

Bug: T277511
Change-Id: I338ee9313e08bda8b22b683281dad3b0e616fd18
2021-11-19 10:56:25 +02:00
vladshapik
9b92c1088f Drop User methods which were deprecated since 1.35
The following User methods, deprecated in 1.35, have been removed:
  - ::isIP,
  - ::isIPRange,
  - ::isValidUserName,
  - ::isUsableName,
  - ::isCreatableName,
  - ::getCanonicalName,
  - ::addAutopromoteOnceGroups,
  - ::getDefaultOptions,
  - ::getDefaultOption,
  - ::getOptions,
  - ::getBoolOption,
  - ::getIntOption,
  - ::setOption
  - ::listOptionKinds
  - ::getOptionKinds,
  - ::resetOptions,
  - ::getEffectiveGroups,
  - ::getAutomaticGroups,
  - ::getFormerGroups
User::GETOPTIONS_EXCLUDE_DEFAULTS has been removed, since it is used only in the description of User::getOptions.

Bug: T277511
Depends-On: Ida05c22f81b30d9b46678e8ede3d531c38855d83
Change-Id: I72bbc2336f8ddbc66ce67226cd2d5baaa2f807d8
2021-11-12 15:35:50 +02:00
vladshapik
8d2be7706d Drop User::getRights()
Deprecated since 1.34 and unused.

Bug: T277511
Change-Id: Ia798c62cdfe6ad6c6d7af8d68b95231883a071fe
2021-11-09 19:20:41 +02:00
vladshapik
aac67c6c38 Drop User methods which were deprecated since 1.37
The following User methods, deprecated in 1.37, have been removed:
- ::resetIdByNameCache,
- ::getStubThreshold,
- ::matchEditTokenNoSuffix,
- ::changeableByGroup
- ::changeableGroups,
- ::isAllowUsertalk
ActorStore::clearCaches() has been removed, since User::resetIdByNameCache
has been removed. User::$mAllowUsertalk has been removed, since
User::isAllowUsertalk has been removed.

Bug: T277511
Change-Id: I608a5277924fc50cc3d9fca6ba958bc6d9c321d0
2021-11-06 07:24:08 -07:00
Cindy Cicalese
b0c0a934e4 Remove hard deprecated Watchlist methods in User, Title, and WatchAction
Bug: T292464
Change-Id: Ie9cb3036a69810344971c49c424a76c7fa1cba07
2021-10-04 15:14:24 -04:00
vladshapik
12b42e8023 Hard deprecate User::blockedby(), User::getblockid()
Bug: T290869
Change-Id: If2d96705223bd80ffd68526773a2c81aaeaa898d
2021-09-28 12:50:29 +00:00
Alexander Vorwerk
04dfdc3653 Hard deprecate User::setOption()
deprecated since 1.35

Bug: T277818
Change-Id: Ic251d624e5d6fa857aa92f9c5dd3df44714ac610
2021-09-26 17:18:54 +02:00
Petr Pchelko
5afc62f258 Remove stub threshold feature
Bug: T284917
Change-Id: I5c9ea04a9deca136bb7210f07200d18f97fd6686
2021-09-13 09:26:38 -07:00
Reedy
7a17473dd1 Remove PasswordCannotMatchUsername password policy
Bug: T242768
Change-Id: Ied6fe389a1ce6c66cbf558d2f3867fb12245ff8a
2021-09-06 14:55:12 +00:00
Alexander Vorwerk
3f06dfb475 Hard deprecate User::getBoolOption()
deprecated since 1.35

Bug: T277600
Change-Id: I54cea0dc589dc5bb7ed3b4ecceaa62b693b104d7
2021-09-04 09:52:06 +02:00
Alexander Vorwerk
0d48f7d25b Hard deprecate User::getIntOption()
deprecated since 1.35 and unused

Bug: T274211
Change-Id: If739492953ee53a39c81894c48f16be81c845542
2021-08-11 14:16:40 +02:00
Tim Starling
088a313fec ContribsPager row filtering with RevisionStore::isRevisionRow
Flow hooks into ContribsPager, causing formatRow() to be called with
FormatterRow objects instead of stdClass objects. formatRow() is
expected to silently decline to format such objects, leaving formatting
up to a subsequent hook.

Instead of calling newRevisionFromRow with all warnings suppressed and
all exceptions caught, provide isRevisionRow() which determines whether
the row is valid. Thus, unexpected exceptions will be visible and the
code does not depend on details of how newRevisionFromRow() validates
its arguments.

Bug: T288563
Change-Id: Id0316886d770cd905897d515b3eb658a5875bd80
2021-08-10 17:59:30 -07:00
Umherirrender
134045b9aa tests: Swap assertion order in unit tests
Changes from patch set Icb93c79f4843b59dae80d3eda1a880457a1a68f2
Also some swaps from assertEquals to assertSame/True/False/Null

Change-Id: Ife497ae6cb1888b77eb25e85b76df72adc65641a
2021-08-04 20:21:01 +02:00
TChin
48496b8526 Support fluent interface for PageUpdater
Also refactored some calls to use it.

Bug: T287484
Change-Id: Ibb745e0131761600789dcb1a2065a981a65ec515
2021-07-29 12:09:37 -04:00
vladshapik
c7e6c67dc5 Hard deprecate User group methods
1) The following methods were hard deprecated:
- User::addAutopromoteOnceGroups
- User::getEffectiveGroups
- User::getAutomaticGroups
- User::getFormerGroups

2) User ::getGroups, ::getGroupMemberships, ::addGroup,
::removeGroup were replaced in the production code,
but they were not hard deprecated because of conflict
with UserRightsProxy class.

Bug: T275148
Change-Id: Ia69598316f5dc5dd9511f6112b5b13e1aa07575a
2021-07-23 15:00:16 +03:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
jenkins-bot
8e20e195eb Merge "Authority: expose user block info" 2021-06-30 15:12:06 +00:00
daniel
b3b70624c9 Authority: expose user block info
Expose info about user blocks from Authority. This allows calling code
to provide more detailed information to the user about why they are
denied some action on the wiki.

Bug: T271494
Change-Id: Ia84e469888866d72752aad355292666c31e12bad
2021-06-30 13:42:21 +02:00
DannyS712
4f9970f30b Fix a bunch of random typos
* yeild -> yield
* paramter -> parameter
* seperator -> separator
* neccesary -> necessary
* inital -> initial
* intial -> initial
* repsonse -> response
* retreived -> retrieved

Bug: T201491
Change-Id: I461941b027590997448f3bdd8a137a48bb338beb
2021-06-29 11:32:04 +00:00
DannyS712
b45ddb2ab3 Use WikiPage::doUserEditContent() instead of ::doEditContent()
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.

Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
2021-06-28 00:11:30 -07:00
Petr Pchelko
ae3d709b22 Make CentralIdLookup a service
This commit is a combination of work done by Tgr in
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/571411
and MaxSem in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/594533
It was just easier to create a brand new patch then
rebase old ones.

Bug: T265767
Change-Id: I3930dab70846e95154d9089905c446e721ef4ee7
2021-06-24 08:37:55 -07:00
DannyS712
b82cf00983 Remove User::$mEditCount and internal caching
UserEditTracker now returns null for anonymous users
instead of throwing an exception.

Added new UserEditTracker::setCachedUserEditCount()
method (internal) to handle the user_editcount field
in User::loadFromRow()'s row. This now means that
the creation of one User object can set the cached
value for any other object for the same underlying user
- the alternative (just ignoring the value) would mean
that an extra database read might be needed. This is
only used for users created with a row that includes
the user id - we silently discard the value if
the row doesn't have a user id (or the user id is 0)
to avoid issues with UserEditTracker trying to fetch
the user id and potentially triggering another load.

A follow-up will simplify the UserEditCountUpdate class
to remove storing full UserIdentity objects now that
only the id is needed.

Follow-up: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
Change-Id: Ie3fb4887d9f2d96b32598865030351bf3bf20ce5
2021-06-18 00:25:47 +00:00
Roman Stolar
4613e36b97 Hard deprecated DatabaseBlock options 'byText' and 'by' with user ID
Bug: T283641
Change-Id: Id1444253b26605f4c68b4cbeb61dc2299ed8ac34
2021-06-04 17:33:48 +03:00
Vlad.shapik
9763c48d17 Reapply "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName""
This reverts commit ecf826a2ee.

Reason for revert: need to edit the patch and then it will be GTG in order to finish hard deprecating of User ::getCanonicalName, ::isUsableName, ::isCreatableName

Change-Id: I2f57f56728fcbeada96dc2228f07dc8bcaa5d4f6
2021-05-31 16:01:36 +03:00
Ppchelko
5596e5784a Remove usages and hard deprecate User::changeable(By)Group
This commit was reverted before cause it has changed the initialization order
and broke FlaggedRevs. Now FlaggedRevs issue was addressed, so we can apply
it back.

Bug: T254838
Change-Id: Id29024caf06fcd0d7d4e039aea8142e8131d47a7
2021-05-27 13:54:29 +00:00
Ppchelko
1d3d790edb Move User::changeable(By)Groups methods to UserGroupManager
Bug: T254838
Change-Id: I5868ed76c7af2adb027bad0aab4bbc8adb6daeb2
2021-05-25 21:09:38 -07:00
Alexander Vorwerk
88a70e066c Hard deprecate User::getRights()
deprecated since 1.34 and unused in Wikimedia deployed repositories.

Bug: T274211
Change-Id: If00e52255b8f555f0e60584c44970c42afe0270e
2021-05-24 11:11:40 +02:00
Petr Pchelko
7136d671d2 Replace User::idFromName with ActorStore
Depends-On: I87fdac02a88aba52a2174949f8736a9a36d3edf7
Depends-On: I812c49009665515778cd354d6c62a17ee24f3625
Change-Id: I5369e9714a3ec653c19ad81f02402e4aa1b22553
2021-05-11 07:44:38 -07:00
James D. Forrester
6bbad15444 User: Hard-deprecate the confusingly-named isLoggedIn() method
This was soft-deprecated in 0171846c, since when all uses in Wikimedia
production code have been removed. As this is such a vital and widely-
used method, we'll want to deprecate it for at least two releases. and
so we should get this in at a time when we're willing to fix many such
uses. Why not now?

Bug: T270450
Change-Id: I8ac4a91d77c2bb748183b69b3e901cce93cbc940
2021-05-10 07:30:23 -07:00
DannyS712
31676abea5 Add DummyServicesTrait::getDummyInterwikiLookup
Replacing the mock InterwikiLookup used in
MediaWikiTitleCodecTest revealed that that test was,
because of the mock not behaving correctly, testing the
wrong thing - interwiki prefixes are *not* case sensitive,
and are always converted to lowercase in the actual
ClassicInterwikiLookup. Fixed those expectations.

Change-Id: I242431e88860b7700a9f93f77a0fe195fd748800
2021-05-05 10:57:59 -07:00
jenkins-bot
67d261449a Merge "Hard deprecate watchlist methods in User" 2021-05-05 17:25:02 +00:00
jenkins-bot
d7083856d9 Merge "Revert "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName"" 2021-05-05 02:45:35 +00:00
Ppchelko
ecf826a2ee Revert "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName"
This reverts commit b491279268.

Reason for revert: caused CentralAuth tests to fail.

Change-Id: Icb3ed094578df427622e0da2a7462645adcc3d6f
2021-05-05 02:14:47 +00:00
jenkins-bot
1ed7dcd022 Merge "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName" 2021-05-04 23:35:53 +00:00
DannyS712
40eda16b0e Remove deprecated talk page message handling in User class
Most needed for moving forward with the removal of uses
of the Revision class, and remove User::getNewtalk at
the same time to be consistent. All of this code was
already hard deprecated in 1.35.

- User::getNewtalk
- User::getNewMessageLinks (could return Revision objects)
- UserRetrieveNewTalks hook (could return Revision objects)
- User::getNewMessageRevisionId (used ::getNewMessageLinks)
- User::setNewtalk (accepted Revision object parameters)

Bug: T247143
Bug: T277511
Change-Id: Ib4fd1e4cbc5ba1497658190b6c6ea3c6a5dc97f0
2021-05-04 19:21:06 +00:00
vladshapik
b491279268 Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName
Bug: T275030
Change-Id: I60689ee6519c2dbd6d000afa8ac05c3e6b7895d2
2021-05-04 21:20:50 +03:00
DannyS712
c6216377bb Remove deprecated https-related hooks
All hard deprecated in 1.35
* BeforeHttpsRedirect
* CanIPUseHTTPS
* UserRequiresHTTPS

Also soft deprecate the wfCanIPUseHTTPS
method, which always returns true. Will
be hard deprecated once callers are updated

Change-Id: Ie6d71809d09edf6be9b8280debeb152ef7fce398
2021-04-30 11:53:18 -07:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Cindy Cicalese
3069e1c428 Hard deprecate watchlist methods in User
Bug: T281187
Depends-On: Id380a5441e30041b6fb79f6ad1fc0506b6a770f9
Depends-On: Ib8bf129a8f31ca054a74a9ec07a1ca0f7ac3e68c
Depends-On: Iddcd1cbf67ad1f8e918c1da07347dd19e5f6f7d9
Change-Id: Ief54eeb149e44ca7ffb2fddb1ba7fbe0e3eb62ea
2021-04-28 23:38:27 +00:00
vladshapik
9cc797695b Hard deprecate User ::isIP, ::getOptions
Bug: T275602
Change-Id: Id4be13751ca0a900e51214c1855a4624077a5a62
2021-04-26 16:10:24 +00:00