From: James D. Forrester Date: Wed, 31 Oct 2018 15:50:46 +0000 (-0700) Subject: Follow-up d67121f6d: Blocks can apply to non-User objects too X-Git-Tag: 1.34.0-rc.0~3521^2~1 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=eab725e3f16df3319b3087b8c0363827ff1f72b2;p=lhc%2Fweb%2Fwiklou.git Follow-up d67121f6d: Blocks can apply to non-User objects too Bug: T208398 Change-Id: I1d39f4ff709f37e7047f49964101e83c97cda0e9 --- diff --git a/includes/Block.php b/includes/Block.php index befc50c889..39f2b2990b 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -767,6 +767,7 @@ class Block { } $target = $block->getTarget(); + // FIXME: Push this into getTargetActor() or whatever to reuse if ( is_string( $target ) ) { $target = User::newFromName( $target, false ); } @@ -1594,6 +1595,7 @@ class Block { * @param User|string $user Local User object or username string */ public function setBlocker( $user ) { + // FIXME: Push this into getTargetActor() or whatever to reuse if ( is_string( $user ) ) { $user = User::newFromName( $user, false ); } @@ -1802,11 +1804,18 @@ class Block { public function preventsEdit( \Title $title ) { $blocked = $this->isSitewide(); - // user talk page has it's own rules + // user talk page has its own rules // This check happens before partial blocks because the flag // to allow user to edit their user talk page could be // overwritten by a partial block restriction (E.g. user talk namespace) $user = $this->getTarget(); + + // Not all blocked `$user`s are self::TYPE_USER + // FIXME: Push this into getTargetActor() or whatever to reuse + if ( is_string( $user ) ) { + $user = User::newFromName( $user, false ); + } + if ( $title->equals( $user->getTalkPage() ) ) { $blocked = $this->prevents( 'editownusertalk' ); }