X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=bdc6702f917d82d992dd280301de44acd35c5303;hb=656f60c15434afb69d60e511cfebf84fc4fbc2c2;hp=d1e78bb6cf791dbdfe443d1d65e2cc812d229bbd;hpb=50495b4f4e356882dd464685cc6f32b415371233;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index d1e78bb6cf..bdc6702f91 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -222,7 +222,7 @@ class Block { 'ipb_block_email', 'ipb_allow_usertalk', 'ipb_parent_block_id', - ] + CommentStore::newKey( 'ipb_reason' )->getFields(); + ] + CommentStore::getStore()->getFields( 'ipb_reason' ); } /** @@ -235,7 +235,7 @@ class Block { * - joins: (array) to include in the `$join_conds` to `IDatabase->select()` */ public static function getQueryInfo() { - $commentQuery = CommentStore::newKey( 'ipb_reason' )->getJoin(); + $commentQuery = CommentStore::getStore()->getJoin( 'ipb_reason' ); return [ 'tables' => [ 'ipblocks' ] + $commentQuery['tables'], 'fields' => [ @@ -460,9 +460,9 @@ class Block { // I wish I didn't have to do this $db = wfGetDB( DB_REPLICA ); $this->mExpiry = $db->decodeExpiry( $row->ipb_expiry ); - $this->mReason = CommentStore::newKey( 'ipb_reason' ) + $this->mReason = CommentStore::getStore() // Legacy because $row may have come from self::selectFields() - ->getCommentLegacy( $db, $row )->text; + ->getCommentLegacy( $db, 'ipb_reason', $row )->text; $this->isHardblock( !$row->ipb_anon_only ); $this->isAutoblocking( $row->ipb_enable_autoblock ); @@ -654,7 +654,7 @@ class Block { 'ipb_block_email' => $this->prevents( 'sendemail' ), 'ipb_allow_usertalk' => !$this->prevents( 'editownusertalk' ), 'ipb_parent_block_id' => $this->mParentBlockId - ] + CommentStore::newKey( 'ipb_reason' )->insert( $dbw, $this->mReason ); + ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->mReason ); return $a; } @@ -670,7 +670,7 @@ class Block { 'ipb_create_account' => $this->prevents( 'createaccount' ), 'ipb_deleted' => (int)$this->mHideName, // typecast required for SQLite 'ipb_allow_usertalk' => !$this->prevents( 'editownusertalk' ), - ] + CommentStore::newKey( 'ipb_reason' )->insert( $dbw, $this->mReason ); + ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->mReason ); } /** @@ -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; }