Add CompositeBlock class for enforcing multiple blocks
authorThalia <thalia.e.chan@googlemail.com>
Tue, 19 Mar 2019 18:56:10 +0000 (18:56 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Wed, 12 Jun 2019 18:16:52 +0000 (19:16 +0100)
commit1eaf65d0a5f551216668a9e434ce323f0ba7dafe
treedd10ba26b38dad29feb6f1692270bc59c4f49de6
parente23501d4b2477bf1d68a89e750ef69b6e783ea7c
Add CompositeBlock class for enforcing multiple blocks

Create a CompositeBlock class which extends AbstractBlock and
adds the property $originalBlocks. This is for situations where
more than one block applies to a user/IP, and avoids the need
to choose just one of these blocks to enforce.

Behaviour of the resulting block is determined by combining the
strictest parameters of the original blocks.

Also add DatabaseBlock::newListFromTarget, which is similar to
DatabaseBlock::newFromTarget, but returns all relevant blocks,
rather than choosing the most specific one.

For tracking a CompositeBlock with a cookie, examine the
original blocks and only track the first trackable block that
is found.

Bug: T206163
Change-Id: I088401105ac8ceb2c6117c6d2fcdb277c754d882
includes/block/BlockManager.php
includes/block/CompositeBlock.php [new file with mode: 0644]
includes/block/DatabaseBlock.php
includes/user/User.php
tests/phpunit/includes/block/CompositeBlockTest.php [new file with mode: 0644]
tests/phpunit/includes/user/PasswordResetTest.php
tests/phpunit/includes/user/UserTest.php