Separate Block into AbstractBlock, Block and SystemBlock
authorThalia <thalia.e.chan@googlemail.com>
Mon, 18 Mar 2019 22:09:49 +0000 (22:09 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Tue, 7 May 2019 22:36:31 +0000 (17:36 -0500)
commit824655f3b74e3275458169f2c87fa81f3598204e
tree458d2b348c132972582d135c02d3c013a3fc4f41
parent781049f1be8dc4f963a6cc17eba57d7143e71822
Separate Block into AbstractBlock, Block and SystemBlock

This commit splits the existing Block class into AbstractBlock, Block
and SystemBlock.

Before this patch, the Block class represents several types of
blocks, which can be separated into blocks stored in the database,
and temporary blocks created by the system. These are now
represented by Block and SystemBlock, which inherit from
AbstractBlock.

This lays the foundations for:
* enforcing block parameters from multiple blocks that apply to a
user/IP address
* improvements to the Block API, including the addition of services

Breaking changes: functions expecting a Block object should still
expect a Block object if it came from the database, but other
functions may now need to expect an AbstractBlock or SystemBlock
object. (Note that an alternative naming scheme, in which the
abstract class is called Block and the subclasses are DatabaseBlock
and SystemBlock, avoids this breakage. However, it introduces more
breakages to calls to static Block methods and new Block
instantiations.)

Changes to tests: system blocks don't set the $blockCreateAccount or
$mExipry block properties, so remove/change any tests that assume
they do.

Bug: T222737
Change-Id: I83bceb5e5049e254c90ace060f8f8fad44696c67
15 files changed:
includes/Block.php
includes/api/ApiBase.php
includes/api/ApiBlockInfoTrait.php
includes/block/AbstractBlock.php
includes/block/BlockManager.php
includes/block/SystemBlock.php [new file with mode: 0644]
includes/exception/UserBlockedError.php
includes/user/User.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/Permissions/PermissionManagerTest.php
tests/phpunit/includes/SystemBlockTest.php [new file with mode: 0644]
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
tests/phpunit/includes/user/PasswordResetTest.php
tests/phpunit/includes/user/UserTest.php