jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/397917 )
Change subject: Update for Block::setBlocker() requiring a valid user or
interwiki username
......................................................................
Update for Block::setBlocker() requiring a valid user or interwiki username
In prepraration for the upcoming actor table, Block requires the blockers
to either be a local user or an interwiki username.
We can use CentralIdLookup to check whether the blocker on the foreign wiki
is the same as the local wiki, otherwise fallback to an interwiki username
that uses the wiki as a prefix.
Bug: T182344
Change-Id: Ia3c85fced974a4edabc172bd3ef6a7a255ffa462
(cherry picked from commit 4494e49e2c234bc700c38a26dfa49dfa61998cdf)
---
M includes/GlobalBlock.php
1 file changed, 28 insertions(+), 1 deletion(-)
Approvals:
Chad: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/GlobalBlock.php b/includes/GlobalBlock.php
index 46f1ded..93cafc9 100644
--- a/includes/GlobalBlock.php
+++ b/includes/GlobalBlock.php
@@ -14,7 +14,7 @@
parent::__construct();
$this->error = $error;
- $this->setBlocker( $block->gb_by );
+ $this->setGlobalBlocker( $block );
}
/**
@@ -23,4 +23,31 @@
public function getPermissionsError( IContextSource $context ) {
return $this->error;
}
+
+ /**
+ * Block requires that the blocker exist or be an interwiki username,
so do
+ * some validation to figure out what we need to use (T182344)
+ *
+ * @param stdClass $block DB row from globalblocks table
+ */
+ public function setGlobalBlocker( stdClass $block ) {
+ // If the block was inserted from this wiki, then we know the
blocker exists
+ if ( $block->gb_by_wiki === wfWikiID() ) {
+ $this->setBlocker( $block->gb_by );
+ return;
+ }
+ $user = User::newFromName( $block->gb_by );
+ // If the blocker is the same user on the foreign wiki and the
current wiki
+ // then we can use the username
+ $lookup = CentralIdLookup::factory();
+ if ( $user->getId() && $lookup->isAttached( $user )
+ && $lookup->isAttached( $user, $block->gb_by_wiki )
+ ) {
+ $this->setBlocker( $user );
+ return;
+ }
+
+ // They don't exist locally, so we need to use an interwiki
username
+ $this->setBlocker( "{$block->gb_by_wiki}>{$block->gb_by}" );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/397917
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia3c85fced974a4edabc172bd3ef6a7a255ffa462
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalBlocking
Gerrit-Branch: wmf/1.31.0-wmf.11
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits