Commit graph

599 commits

Author SHA1 Message Date
Lucas Werkmeister
b0d7337ef4 Add CentralIdLookup::factoryNonLocal()
This is basically a workaround for T163277 and T170996: it’s hard to
tell whether the IDs returned by a CentralIdLookup are actually safe to
use cross-wiki or not, so add a factory method which only returns a
CentralIdLookup that can be expected to provide cross-wiki IDs, and
otherwise gives up and returns null.

This is a port of the Wikibase CentralIdLookupFactory class, originally
added in change Ie7b9c482cf by Matthew Flaschen.

Bug: T258390
Change-Id: I903c126be413608bd366875ecc7ac007d4da8e3f
2020-07-21 17:48:19 +02:00
DannyS712
80027cdbbc User is not @newable in 1.36
Bug: T257464
Change-Id: I0d78cfb18166f46a65a65755ca2bef57d504a0b3
2020-07-16 12:14:33 +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
jenkins-bot
453e1357ee Merge "Update stability annotations to follow new stable interface policy" 2020-07-13 10:05:02 +00:00
jenkins-bot
6a20eebf3d Merge "Mark potential abstract classes stable for subclassing" 2020-07-13 09:48:26 +00:00
daniel
48eb174759 Update stability annotations to follow new stable interface policy
This is a follow-up to I1939bb11038ec2.

Bug: T247862
Change-Id: I69a1ec1700bfb68a36003d65cc2184f23f208794
2020-07-13 09:40:54 +00:00
jenkins-bot
a5f4732261 Merge "Replace "@stable for implementation" with "@stable to implement"" 2020-07-13 09:31:44 +00:00
daniel
e6e0ad2472 Replace "@stable for implementation" with "@stable to implement"
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: I17e5e92e24c708ffc846945a136347670a3a20c7
2020-07-13 11:05:49 +02: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
Ammar Abdulhamid
b19991caef Remove support for setting IP addresses in the keys of $wgProxyList
Deprecated since 1.30; It was probably supposed to be removed in Ic9cc2a5
(where test for the functionality was also removed).

Bug: T232864
Change-Id: I9eb23c536b3dff07b6b1e2e4fe648ef6fe08bc6e
2020-07-12 19:26:39 +00:00
Ammar Abdulhamid
6cbd116954 Remove selectFields User method
* Deprecated since 1.31
* Remaining call in Test replaced

Bug: T249181
Change-Id: Idb69f36a07055110fe0b7540186b23cc52dad76f
2020-07-12 15:21:48 +01:00
Ammar Abdulhamid
4c36dcdede Remove User::setPassword()
Also remove dependent internal method

Deprecated since 1.27, unused in deployed code.

Note that this method has not worked the way it should
since 2016; see T256620#6270262 and subsequent comment

Bug: T249181
Change-Id: I840c4e98ab88401d60b714420ba4233288d94e10
2020-07-12 14:56:24 +01:00
Nikki Nikkhoui
5fb9e95b22 Mark potential abstract classes stable for subclassing
Going through some more abstract classes in core, and
marking those that are extended by extensions as
stable.

I have limited knowledge on the uses of these classes so
marking for vibisility/review.

Bug: T247862
Change-Id: I1939bb11038ec2536eebbdbd12524e83d615b86b
2020-07-11 15:33:34 -07:00
daniel
128565505c Mark additional classes as newable for now.
The following glasses are marked as newable per the
Stable Interface Policy, even though logically, they should not be
newable. This is done for classes that are currently instantiated
by extensions, and lack an alternative.

A better way for obtaining an instance of these classes should be
created in the future. At that point, direct instantiation should
be deprecated and replaced.

- includes/ApiMain.php - needs factory
- includes/media/BitmapMetadataHandler.php - should become a stateless service or use handler pattern
- includes/GitInfo.php - should become a stateless service
- includes/logging/LogPage.php - should become a stateless service or use command pattern
- includes/logging/ManualLogEntry.php - should become a stateless service or use command pattern
- includes/poolcounter/PoolCounterWorkViaCallback.php - needs a factory
- includes/context/RequestContext.php - needs to be narrowed down, and should use a factory
- includes/search/SearchHighlighter.php - should have a factory
- includes/TitleArrayFromResult.php - should perhaps be part of TitleFactory
- includes/user/User.php - should at least get a factory method for anons
- includes/diff/Diff.php: needs a TextDiffGenerator service or a factory
- includes/EditPage.php: needs a factory

Bug: T247862
Change-Id: I033158e693c98630ee167d9528fc8c9936f978d4
2020-07-08 18:06:12 +02:00
Timo Tijhof
262e72f5a1 User: Move per-user logic in pingLimiter() closer together
Clean up for readability, no behavioural difference.

Bug: T246991
Change-Id: Icd4f22cbae7da2dfbca5abe348d91b55985c079a
2020-07-08 06:59:18 +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
jenkins-bot
508b851296 Merge "Debug: include username in User::getBlockedStatus wfDebug call" 2020-07-03 04:23:36 +00:00
jenkins-bot
8b2f44b6e7 Merge "phan: Enable redundant_condition_detection" 2020-07-02 00:28:10 +00:00
Umherirrender
bc5cb7ae64 phan: Enable redundant_condition_detection
Remove duplicate casts
Suppress false positives

Bug: T248438
Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
2020-07-01 20:13:07 +00:00
Tim Starling
c75eef91bf Introduce $wgForceHTTPS
Add $wgForceHTTPS. When set to true:

* It makes the HTTP to HTTPS redirect unconditional and suppresses the
  forceHTTPS cookie.
* It makes session cookies be secure.
* In the Action API, it triggers the existing deprecation warning and
  avoids more expensive user/session checks.
* In login and signup, it suppresses the old hidden form fields for
  protocol switching.
* It hides the prefershttps user preference.

Other changes:

* Factor out the HTTPS redirect in MediaWiki::main() into
  maybeDoHttpsRedirect() and shouldDoHttpRedirect(). Improve
  documentation.
* User::requiresHTTPS() reflects $wgForceHTTPS whereas the Session
  concept of "force HTTPS" does not. The documentation of
  User::requiresHTTPS() says that it includes configuration, and
  retaining this definition was beneficial for some callers. Whereas
  Session::shouldForceHTTPS() was used fairly narrowly as the value
  of the forceHTTPS cookie, and injecting configuration into it is not
  so easy or beneficial, so I left it as it was, except for clarifying
  the documentation.
* Deprecate the following hooks: BeforeHttpsRedirect, UserRequiresHTTPS,
  CanIPUseHTTPS. No known extension uses them, and they're not compatible
  with the long-term goal of ending support for mixed-protocol wikis.
  BeforeHttpsRedirect was documented as unstable from its inception.
  CanIPUseHTTPS was a WMF config hack now superseded by GFOC's SNI
  sniffing.
* For tests which failed with $wgForceHTTPS=true, I mostly split the
  tests, testing each configuration value separately.
* Add ArrayUtils::cartesianProduct() as a helper for generating
  combinations of boolean options in the session tests.

Bug: T256095

Change-Id: Iefb5ba55af35350dfc7c050f9fb8f4e8a79751cb
2020-06-30 15:38:11 +10:00
jenkins-bot
5b0e900eac Merge "Use TitleParser in UserNameUtils" 2020-06-28 11:42:10 +00:00
DannyS712
0562a66579 Debug: include username in User::getBlockedStatus wfDebug call
Change-Id: I707ff54fe2e7bc32d35c68086ec9904c91f6e8e0
2020-06-26 00:57:20 +00:00
jenkins-bot
2ea576ee51 Merge "Hard deprecate User::getNewtalk and User::setNewtalk" 2020-06-25 18:56:13 +00:00
Clara Andrew-Wani
4093985c28 Hard deprecate User::getNewtalk and User::setNewtalk
Bug: T239640
Change-Id: I7f901963ea67e8cdac1611838570ff9717d11232
2020-06-25 12:12:32 -04:00
jenkins-bot
bba5dcc76e Merge "Remove User::setInternalPassword()" 2020-06-25 13:47:06 +00:00
Ammar Abdulhamid
4477f9b7f6 Remove User::setInternalPassword()
Deprecated since 1.27, unused in deployed code.

There's one usage in one extension that's already broken for other reasons

Bug: T249181
Change-Id: I2b868060dd394fb29e389628b659c0d1b3f11833
2020-06-25 13:04:09 +01:00
Ammar Abdulhamid
6164bb3f0c Drop User::checkPassword()
Hard-deprecated since 1.27 and no callers

Bug: T249181
Change-Id: Iee36a1107dbed105456f6a645f62f1d572d4a9fc
2020-06-25 11:52:57 +01:00
Thalia
9132b2e372 User: Remove useless check from deprecated isBlocked method
Remove call to AbstractBlock::appliesToRight, because it always
returns true for 'edit', so checking it is equivalent to adding
&& true.

Although this method is deprecated, this is worth tidying this up
since it is confusing and gets us one step closer to removing the
'edit' case altogether.

Change-Id: I479d6c866ec13a791873042e623fa841dd5bebf2
2020-06-24 23:43:11 +01:00
jenkins-bot
a4fd6ef060 Merge "Hard-deprecate UserGroupMembership methods replaced by manager" 2020-06-24 18:35:42 +00:00
jenkins-bot
a7dae830b3 Merge "Introduce wfDeprecatedMsg()" 2020-06-22 22:30:49 +00:00
jenkins-bot
be6df9ec5b Merge "User: Fix pingLimiter() to use makeGlobalKey() for global rate limits" 2020-06-22 22:01:29 +00:00
Timo Tijhof
11bf9b13cf User: Fix pingLimiter() to use makeGlobalKey() for global rate limits
It was previously forging keys without any makeKey() call in a way
that does produce the same string regardless of wiki, however
bypassing makeKey() means the cache key might end up containing
illegal characters (and thus fatal). It also means that any
logic for detecting local vs global keys for sharding purposes
would wrongly intepret this as a wiki-local key which could cause
split-brain scenarios.

Bug: T246991
Change-Id: I83d0e11d84e3cdcfc8916b2a9b8d85db7c42d2a7
2020-06-22 21:37:12 +00:00
Tim Starling
d459add63d Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.

However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."

So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().

Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-22 14:34:39 +10:00
Umherirrender
fd666afbb0 Use MediaWikiServices::getAuthManager instead of AuthManager::singleton
Change-Id: I92c31b963095eab751df9f8c1715e8e23b7e8485
2020-06-22 00:57:08 +00:00
Umherirrender
be57334d8d Use TitleParser in UserNameUtils
Bug: T245231
Change-Id: I405c26f7a7a1bc3dedaeab4d28ff2d547922fc44
2020-06-21 21:28:03 +02:00
Thalia
14bb09fe7f 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
2020-06-17 12:51:13 +01:00
jenkins-bot
e862341ce0 Merge "Move User::newFromIdentity logic to UserFactory" 2020-06-15 20:26:57 +00:00
jenkins-bot
2f9ccec7d3 Merge "Followups for UserGroupManager" 2020-06-15 14:50:34 +00:00
Petr Pchelko
c8d3f524ee Followups for UserGroupManager
1. User::addGroup has to be allowed to update the old group
2. Replace use of string constants to identify cache class,
that's prone to typos and errors. Instead, use private constants
3. Update cached user group memberships in place upon modification.
Before UserGroupManager, we've used to do that - this saves some
DB queries, and is better for correctness - for example UserrightsPage
is adding new memberships and then immediately reads from replica,
expecting it's changes to be there already.
We do not know however how many other cases there are which rely
on this pattern, so implement in-place cache update.

Bug: T255330
Change-Id: Ia5ae0e22d4156fd5e4b9aa7eeb801902e79803d1
2020-06-15 07:10:13 -07:00
Petr Pchelko
62f2dc26ee Hard-deprecate UserGroupMembership methods replaced by manager
Bug: T234921
Change-Id: Id4a700f921d5453dcdd7e1d3b2370dada25328a6
2020-06-12 14:36:26 -07:00
Petr Pchelko
d00dfbd756 Move User::addAutopromoteOnceGroups to UserGroupManager
Additionally, User::checkAndSetTouched was made public and
marked as @internal. Eventually, as User class refactoring
continues, I would expect this to be replaced by some service.

Bug: T252621
Change-Id: I53533f494950d08ee5ed1ec54d24958c21e7b3aa
2020-06-12 12:06:10 -07:00
DannyS712
2d7d99f036 Move User::newFromIdentity logic to UserFactory
Simplest static constructor for Users, no dependencies on anything else

Bug: T253432
Change-Id: Ibe422de4f1753334f2737bc39e077b1e4173ad45
2020-06-12 18:24:49 +00:00
jenkins-bot
c54e76c4ce Merge "Move autopromote groups logic into UserGroupManager" 2020-06-12 18:10:37 +00:00
jenkins-bot
056a7838de Merge "UserOptionsManager: take into account $queryFlags when caching" 2020-06-12 17:33:27 +00:00
jenkins-bot
d80bea822f Merge "UserFactory v.1 - wrapper for User::newFrom* static methods" 2020-06-12 16:29:02 +00:00
Petr Pchelko
cd6b72ecd7 Move autopromote groups logic into UserGroupManager
Bug: T252621
Change-Id: Ic51119cd01771ab1b68294fa5dfacb8034e33b6b
2020-06-11 22:13:48 +00:00
jenkins-bot
6106469ef6 Merge "UserGroupManager: Consider $queryFlags when caching" 2020-06-11 22:03:07 +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
Clara Andrew-Wani
144157dbdb UserGroupManager: Consider $queryFlags when caching
Bug: T254282
Change-Id: I41a31ba6d597c11c7d7c8e753aa0e4c29303d5d9
2020-06-10 15:01:04 -04:00
DannyS712
249aa916d6 Hard deprecate User::getNewMessageLinks
Bug: T253949
Change-Id: I08d1fef9effeab420824c77f6ee7fd468ae51a3a
2020-06-10 02:02:16 +00:00