Commit graph

26 commits

Author SHA1 Message Date
Aryeh Gregor
4b72b9d504 Throw for mismatched wiki in UserIdentity::getId
Bug: T260933
Change-Id: I97579ed0a6160c43fd15503c2e81f131d6806bd2
2022-05-01 17:41:48 +03:00
Alexander Vorwerk
9c97f7a7e4 Follow-Up: I10fbd4b6a: Update @since tags as those were backported
Bug: T281972
Change-Id: Ifef75649e217d4c9d1f5e66bd09116febe242038
2021-11-13 23:02:07 +01:00
TChin
077b9af960 Replace Assert::parameterType with typehints
Bug: T287530
Change-Id: I6060e194339614b53e3a9c036ff3a3ac2e68f8df
2021-08-03 10:03:48 -04: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
Petr Pchelko
5455e58967 Deprecate File::getUser in favor of File::getUploader
Change-Id: I8a45a8fdfa827f203e6bc123cb685d02c3612bb0
2021-06-02 09:06:09 -07:00
James D. Forrester
fb882ada5b Follow-up bbc75d404: Update @since tag as we're back-porting
Bug: T281972
Change-Id: I10fbd4b6af61b3ae46798db11a37674c953694a8
2021-05-11 17:53:39 -07:00
Petr Pchelko
bbc75d4048 UserIdentityValue: Introduce convenience static factory methods
Bug: T281972
Change-Id: I3e65690695313380c798b62edfda726b6e374f89
2021-05-05 11:25:09 -07: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
Vadim Kovalenko
e3fdf34816 Avoid using UserIdentity::getUserId
Bring back replacement of UserIdentity::getUserId with ::getId
Add $wikiId = self::LOCAL as an optinal parameter to User and
UserIdentity

Bug: T275482
Depends-On: Ie9fd52005ca1eb264dc791a2f87d7308a9e8810e
Change-Id: Ic80e011bcb97fa682c9249c690bebd4b4326c896
2021-03-08 09:20:24 -05:00
Martin Urbanec
9eb9541038 Re-introduce UserIdentity::getUserId - removed in a violation of SIP
UserIdentity::getUserId was removed by 493105109e
in a violation of [[:mw:SIP]], as the removing developers
did not make sure this change does not affect Wikimedia wikis,
and as getUserId was never hard-deprecated, in fact,
it was _recommended to be used_ by UserIdentity::getId's
soft deprecation.

Reinstante the removed code to unbreak ie. SecurePoll.

Bug: T275482
Change-Id: I306c33165b2bf08602d2bbc60782e0a493405797
2021-03-03 07:40:15 +01:00
Vadim Kovalenko
493105109e Avoid using UserIdentity::getUserId
Replace UserIdentity::getUserId with ::getId
Add $wikiId = self::LOCAL as an optinal parameter to User and
UserIdentity

Bug: T275482
Change-Id: I44494845c469a14284c3e23cb620e5a7cbf59cd5
2021-03-02 16:12:55 -07:00
jenkins-bot
6ca0ab0303 Merge "Implement UserIdentityValue::__toString()" 2021-02-22 19:54:29 +00:00
Petr Pchelko
929ed50fbf Implement UserIdentityValue::__toString()
Currently in some places we pass User as a message parameter.
This works cause User::__toString() returns the user name,
which in general makes sense. Now that we are replacing User
with UserIdentityValue, the UIV instances will start flowing
around in the system more, and some UI messages will definitely
break.

This is not an ideal solution, we probably should have special
ParamType::USER in the Message infrastructure, and have a special
formatter for this type, but it would be extraordinary hard to track
down all the place where this might be needed, so perhaps let's
emulate User behaviour in UserIdentityValue.

Change-Id: I5c6a25234d1599178d08212fb2d2f197b433b164
2021-02-17 14:45:31 -06:00
Cindy Cicalese
2d302a936e Hard-deprecate IDatabase parameter for UserIdentity:getActorId()
Bug: T273576
Change-Id: I0df4a2749afae74671dc4c49bac4e18309677703
2021-02-17 12:51:02 -05:00
jenkins-bot
4478047d6e Merge "Introduce helper WikiAwareEntityTrait" 2021-02-08 20:29:14 +00:00
Petr Pchelko
26be00fac4 Introduce helper WikiAwareEntityTrait
Bug: T273948
Change-Id: I21180d7031646f13413e2edb1bf0a17fbfdada13
2021-02-08 13:49:50 -06:00
Petr Pchelko
8d2c674ab0 Introduce ActorStore, ActorLookup and ActorFactory.
The ActorNormalization factory methods create
UserIdentityValue from the database rows, either via
fields of a joined table, or via a row from actor table.
They assume that the actor_id exist and throw othervise.

ActorNormalization is a storage-layer service providing
access to finding and acquiring actor_id.

The UserIdentityLookup methods do not instantiate new actor
on demand, they just find an appropriate row in the actor
table and return the result.

Bug: T272689
Depends-On: I74d81f3f0233efb17fc8df5178e4c477cc669c6f
Change-Id: Icfa1daca960c696a8cef8adab5eab53985802858
2021-02-08 10:06:46 -06:00
Cindy Cicalese
f992c7d8a3 Add type hints for return types to methods on UserIdentity
Bug: T273285
Change-Id: I0ffc4963e8362264d1f10455af0f6222c05be7d8
2021-02-02 20:58:51 +00:00
Cindy Cicalese
5576727771 Make UserIdentity objects aware of which wiki they belong to.
Bug: T260933
Change-Id: Ic986640cc34e6ec6be239e410a8334f0e299c682
2021-02-02 16:10:51 +00:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
daniel
bd5c3d06a2 Annotate newable classes
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.

Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
2020-07-07 15:38:57 +02:00
Aryeh Gregor
f7201e3b9b Convert WatchedItem and friends to UserIdentity
I wasn't able to port some places that rely on isAllowed, getOption, or
related methods.

This adds isRegistered() to UserIdentity, which works like
User::isLoggedIn() but with a better name.

I also cleaned up User mocks in WatchedItemQueryServiceUnitTest in the
course of debugging test failures when switching them to
UserIdentityValue instead of mock Users where possible. They now specify
explicitly which methods are allowed to be called on their User objects,
which I believe is good practice for mocks (and unfortunately PHPUnit
makes it awkward).

Bug: T207972
Depends-On: I883d506197a011fe4c102b72df4d9deb58ab5ca2
Change-Id: Iadbf7bc31a496899dbef44e49065ff89f37aea89
2019-05-05 14:35:52 +03:00
Gergő Tisza
df1c24fde8
Add equals() to UserIdentity
Change-Id: Ia2f33d551e96bd6f58ba9414049449282575a63b
2018-05-08 16:31:03 +02:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
daniel
e61a1caadd [MCR] Break Revision into RevisionRecord and RevisionStore
Bug: T174025
Change-Id: I140f43a6fb443b38483f41f268c906b9cea64cf7
2017-12-13 22:34:29 +00:00