From eab725e3f16df3319b3087b8c0363827ff1f72b2 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 31 Oct 2018 08:50:46 -0700 Subject: [PATCH] Follow-up d67121f6d: Blocks can apply to non-User objects too Bug: T208398 Change-Id: I1d39f4ff709f37e7047f49964101e83c97cda0e9 --- includes/Block.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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' ); } -- 2.20.1