X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=0999ad20634fe93880f252e6972ddd1c3da1dd89;hb=cc02ef9657935a5036cffcf19f965d64827865ff;hp=d1e78bb6cf791dbdfe443d1d65e2cc812d229bbd;hpb=5120937028f768749d058aa91dde82a96de0af1c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index d1e78bb6cf..0999ad2063 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -1479,9 +1479,19 @@ class Block { /** * Set the user who implemented (or will implement) this block - * @param User|string $user Local User object or username string for foreign users + * @param User|string $user Local User object or username string */ public function setBlocker( $user ) { + if ( is_string( $user ) ) { + $user = User::newFromName( $user, false ); + } + + if ( $user->isAnon() && User::isUsableName( $user->getName() ) ) { + throw new InvalidArgumentException( + 'Blocker must be a local user or a name that cannot be a local user' + ); + } + $this->blocker = $user; }