Separate out different functionalities of Block::prevents
authorThalia <thalia.e.chan@googlemail.com>
Sat, 9 Feb 2019 12:17:54 +0000 (12:17 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Thu, 21 Feb 2019 18:21:28 +0000 (18:21 +0000)
commit02cb7aefef02d5d416ebdb53f9c4767508a99141
tree51de495e2231df9a1c583718d7bc469a82f74c7a
parent5376b0b4b24ab5ca02989e1e10bde672581675f5
Separate out different functionalities of Block::prevents

Block::prevents plays several different roles:
* acts as get/setter for Boolean properties that correspond to
ipb_create_account, ipb_block_email and ipb_allow_usertalk
* calculates whether a block blocks a given right, based on Block
properties, global configs, white/blacklists and anonymous user
rights
* decides whether a block prevents editing of the target's own
user talk page (listed separately because 'editownusertalk' is
not a right)

This patch:
* renames mDisableUsertalk to allowEditUsertalk (and reverses the
value), to match the field ipb_allow_usertalk and make this logic
easier to follow
* renames mCreateAccount to blockCreateAccount, to make it clear
that the flag blocks account creation when true, and make this
logic easier to follow
* decouples the block that is stored in the database (which now
reflects the form that the admin submitted) and the behaviour of
the block on enforcement (since the properties set by the admin
can be overridden by global configs) - so if the global configs
change, the block behaviour could too
* creates get/setters for blockCreateAccount, mBlockEmail and
allowEditUsertalk properties
* creates appliesToRight, exclusively for checking whether the
block blocks a given right, taking into account the block
properties, global configs and anonymous user rights
* creates appliesToUsertalk, for checking whether the block
blocks a user from editing their own talk page. The block is
unaware of the user trying to make the edit, and this user is not
always the same as the block target, e.g. if the block target is
an IP range. Therefore the user's talk page is passed in to this
method. appliesToUsertalk can be called from anywhere where the
user is known
* uses the get/setters wherever Block::prevents was being used as
such
* uses appliesToRight whenever Block::prevents was being used to
determine if the block blocks a given right
* uses appliesToUsertalk in User::isBlockedFrom

Bug: T211578
Bug: T214508
Change-Id: I0e131696419211319082cb454f4f05297e55d22e
RELEASE-NOTES-1.33
includes/Block.php
includes/Title.php
includes/specials/SpecialBlock.php
includes/user/PasswordReset.php
includes/user/User.php
maintenance/cleanupBlocks.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/specials/SpecialBlockTest.php