Block: Clean up handling of non-User targets
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 1 Nov 2018 14:11:03 +0000 (10:11 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 2 Nov 2018 16:33:57 +0000 (12:33 -0400)
commit74ff87d291e6daddfd791270c6ee95ca587d3d46
tree2bd7957639adbe14b5457f00342b7e2b619febf5
parentb86593a2da96539ca60ac7011eda0faf4e9e00d9
Block: Clean up handling of non-User targets

The fix applied in d67121f6d took care of the immediate issue in
T208398, but after further analysis it was not a correct fix.

* Near line 770, the method shouldn't even be called unless the target
  is TYPE_USER.
* Near line 1598, it isn't dealing with a target at all.
* Near line 1813, you're not going to get a sensible result trying to
  call `$user->getTalkPage()` for a range or auto-block ID. What you
  would really need there to handle range and auto-blocks correctly is
  to pass in the User actually making the edit.

But after some pushback in code review about passing the User into
Block::preventsEdit() to make line 1813 work, we'll instead replace the
method with Block::appliesToTitle() and put the check for user talk
pages back into User::isBlockedFrom().

Bug: T208398
Bug: T208472
Change-Id: I23d3a3a1925e97f0cabe328c1cc74e978cb4d24a
includes/Block.php
includes/user/User.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/user/UserTest.php