Commit graph

8 commits

Author SHA1 Message Date
Thalia
786a7a168a Pass in ServiceOptions to BlockManager
Change-Id: Ic63d7ff35a71e36c4e6157e9d472e2870f95f00d
2019-07-10 16:33:21 +01:00
Thalia
4b90befa9a Tidy up conditions for applying a block from a cookie
Change-Id: Id9dd6ae395f5bb811db4c741be9db8aa2eb6fb70
2019-07-10 16:28:55 +01:00
Max Semenik
c873333333 Defer cookie block checks to resolve a circular dependency
User needs to load user preferences to get preferred language, which
calls User::load() which calls User::loadFromSession().

User::loadFromSession() tries to load blocks which might use messages
which need user language which calls User::load() because the previous
call to it haven't completed yet...

We have a protection against infinite recursion to prevent this from
completely crashing MW, however this patch fixes the main issue: loading
too much stuff when a User is initialized.

Bug: T180050
Change-Id: I63af6d2239b36124d5ed382b8d2aab82c8d54d69
2019-06-27 22:37:44 -07:00
Thalia
9510597f26 Filter out duplicate autoblocks when checking for blocks
Follow-up to I7654907.

Bug: T225919
Change-Id: I67e72d6c88e3cbfd9515a016b2782d1d9b123775
2019-06-20 22:01:44 +01:00
Thalia
c5991f614f Move cookie-blocking methods to BlockManager
Move the cookie blocking logic into one place. Specifically, move
these methods to the BlockManager:
* User::trackBlockWithCookie
* DatabaseBlock::setCookie
* DatabaseBlock::clearCookie
* DatabaseBlock::getCookieValue
* DatabaseBlock::getIdFromCookieValue
* AbstractBlock::shouldTrackWithCookie

After this, BlockManager::trackBlockWithCookie should be called to
track a block, and BlockManager::clearBlockCookie should be called
to unset the cookie. The other methods in the above list are
helper methods that are made private or marked internal.

Also update places in core that call User::trackBlockWithCookie to
BlockManager::trackBlockWithCookie

Bug: T225141
Change-Id: I818962c6932c01c841a549a101637e00a7593e48
2019-06-11 15:08:21 +01:00
Thalia
e65a5b5882 Rename Block to MediaWiki\Block\DatabaseBlock
Keep Block as a deprecated class alias for DatabaseBlock.
Update calls to the Block constructor and Block static
methods from external classes.

Also update documentation in several places that refer to
blocks as Blocks.

Bug: T222737
Change-Id: I6d96b63ca0a84bee19486471e0a16a53a79d768a
2019-05-28 12:20:48 +01:00
Thalia
e9714e6a8d Make improvements to BlockManagerTest
Remove reliance on real domain and add more test cases.

Change-Id: Icd67fe8c1c9223a92a3775d34d0453328442d89e
2019-05-27 23:30:24 +01:00
Thalia
52f7720227 Introduce a BlockManager service
This introduces a minimal BlockManager service, for getting blocks
that apply to a User.

Move the part of User::getBlockedStatus that checks for the blocks
into BlockManager::getUserBlock, and move the related helper
methods from User to BlockManager.

Hard deprecate or remove these helper methods, and move to private
methods in the BlockManager:
* User::getBlockFromCookieValue
* User::isLocallyBlockedProxy
* User::inDnsBlacklist

Soft deprecate these helper methods, and move to public methods in
the BlockManager:
* User::isDnsBlacklisted

Add tests to cover the methods moved to BlockManager.

Bug: T219441
Change-Id: I0af658d71288376735cebe541215383b56bb72e5
2019-04-29 17:47:55 +01:00