Deprecate User::isBlocked()
authorDavid Barratt <dbarratt@wikimedia.org>
Tue, 23 Apr 2019 17:51:54 +0000 (13:51 -0400)
committerDavid Barratt <dbarratt@wikimedia.org>
Thu, 25 Apr 2019 15:47:44 +0000 (11:47 -0400)
commite86a060284e8ade65ca1e358b0b449fd0c0d9559
treeb6cb0ab4f36d6b7641d6ea2d11b88981c13950a1
parent44a2f3e5ee6d4f1d484f9878de4c22c0e7d8d76d
Deprecate User::isBlocked()

The method User::isBlocked() attempts to answer two questions:
(1) Does the user have a block?
(2) Is the user prevented from performing this action?
The method can answer #1, but it cannot answer #2. Since User::getBlock() can
also answer #1, this method is redundant. The method cannot answer #2 because
there is not enough context in order to answer that question.

If access is being checked against a Title object, all access checks can be
performed with PermissionManager:userCan() which will also check the user's
blocks.

If performing all access checks is not desirable, using
PermissionManager::isBlockedFrom() is also acceptable for only checking if the
user is blocked. This method does *not* determine if the action is allowed,
only that the user's block applies to that Title.

If access is being checked without an existing Title, User::getBlock() can be
used to get the user's block. Then Block::appliesToRight() can be used to
determine if the block applies explicitly to a right (or returns null if
it is unknown or false if explicitly allowed). If the user is creating a new
Title, but the text of the title is not yet known (as in the case of Wikibase),
access should be checked with Block::appliesToNamespace().

Bug: T209004
Change-Id: Ic0ad1b92e957797fee8dcd00bd1092fe69fa58f1
19 files changed:
RELEASE-NOTES-1.34
includes/Autopromote.php
includes/api/ApiBlock.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiRevisionDelete.php
includes/api/ApiTag.php
includes/api/ApiUnblock.php
includes/api/ApiUserrights.php
includes/auth/CheckBlocksSecondaryAuthenticationProvider.php
includes/changetags/ChangeTags.php
includes/mail/EmailNotification.php
includes/specials/SpecialBlock.php
includes/specials/SpecialContributions.php
includes/specials/SpecialEditTags.php
includes/specials/SpecialRevisionDelete.php
includes/specials/SpecialUserrights.php
includes/user/User.php
maintenance/importImages.php
tests/phpunit/includes/user/UserTest.php