Merge "Add SPARQL client to core"
[lhc/web/wiklou.git] / includes / Block.php
index d1e78bb..bdc6702 100644 (file)
@@ -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;
        }