Anomie has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386626 )

Change subject: Update for core interwiki user handling change
......................................................................

Update for core interwiki user handling change

MediaWiki core change I5401941 is doing two things that are relevant to
CentralAuth:

* The 'byText' parameter to Block may no longer name a usable name that
  doesn't exist locally.
* Imports may call a new ImportHandleUnknownUser hook to give extensions
  a chance to auto-create users.

For the first, we introduce a new $wgCentralAuthGlobalBlockInterwikiPrefix
variable that holds an interwiki prefix to prepend to the value passed
to byText to make it an invalid username. Core changes to Linker will
interpret this properly in block logs and generate an interwiki link.

For the second, we implement the hook to auto-create the local user if
the central user exists.

Note that, while this should work ok without I5401941, it'll start
producing global blocks with interwiki usernames that core will display
in a somewhat strange manner.

Bug: T9240
Bug: T111605
Change-Id: Ieae5d24f9098c1977447c50a8d4e2cab58a24d9f
Depends-On: I4e8b882597d2ed8075a71393e04bb0c36eebb47c
---
M extension.json
M includes/CentralAuthHooks.php
M includes/CentralAuthUser.php
3 files changed, 23 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/26/386626/1

diff --git a/extension.json b/extension.json
index bc11980..b75a4e7 100644
--- a/extension.json
+++ b/extension.json
@@ -388,6 +388,7 @@
                "SecurePoll_GetUserParams": 
"CentralAuthHooks::onSecurePoll_GetUserParams",
                "DeleteAccount": "CentralAuthHooks::onDeleteAccount",
                "SessionCheckInfo": "CentralAuthHooks::onSessionCheckInfo",
+               "ImportHandleUnknownUser": 
"CentralAuthHooks::onImportHandleUnknownUser",
                "UnitTestsAfterDatabaseSetup": 
"CentralAuthHooks::onUnitTestsAfterDatabaseSetup",
                "UnitTestsBeforeDatabaseTeardown": 
"CentralAuthHooks::onUnitTestsBeforeDatabaseTeardown"
        },
@@ -435,6 +436,7 @@
                "CentralAuthCheckSULMigration": false,
                "CentralAuthGlobalPasswordPolicies": [],
                "CentralAuthUseSlaves": false,
+               "CentralAuthGlobalBlockInterwikiPrefix": "global",
                "OverrideCentralIdLookupProvider": true
        },
        "AuthManagerAutoConfig": {
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index fae4044..a24917e 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -267,6 +267,25 @@
        }
 
        /**
+        * Auto-create a user on import
+        * @param string $name
+        * @return bool
+        */
+       public static function onImportHandleUnknownUser( $name ) {
+               $user = User::newFromName( $name );
+               if ( $user ) {
+                       $centralUser = CentralAuthUser::getMasterInstance( 
$user );
+
+                       if ( $centralUser->exists() && 
CentralAuthUtils::autoCreateUser( $user )->isGood() ) {
+                               $centralUser->invalidateCache();
+                               return false;
+                       }
+               }
+
+               return true;
+       }
+
+       /**
         * Add a little pretty to the preferences user info section
         *
         * @param User $user
diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index e2705d0..4b81d46 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -1763,7 +1763,7 @@
         * @return array|null Error array on failure
         */
        public function doLocalSuppression( $suppress, $wiki, $by, $reason ) {
-               global $wgConf;
+               global $wgConf, $wgCentralAuthGlobalBlockInterwikiPrefix;
 
                $lb = wfGetLB( $wiki );
                $dbw = $lb->getConnectionRef( DB_MASTER, [], $wiki );
@@ -1786,7 +1786,7 @@
                                'enableAutoblock' => true,
                                'hideName' => true,
                                'blockEmail' => true,
-                               'byText' => $by
+                               'byText' => 
$wgCentralAuthGlobalBlockInterwikiPrefix . '>' . $by
                        ] );
 
                        # On normal block, BlockIp hook would be run here, but 
doing

-- 
To view, visit https://gerrit.wikimedia.org/r/386626
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieae5d24f9098c1977447c50a8d4e2cab58a24d9f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to