jenkins-bot has submitted this change and it was merged. ( 
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(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 09bbbef..ea1690f 100644
--- a/extension.json
+++ b/extension.json
@@ -390,6 +390,7 @@
                "SecurePoll_GetUserParams": 
"CentralAuthHooks::onSecurePoll_GetUserParams",
                "DeleteAccount": "CentralAuthHooks::onDeleteAccount",
                "SessionCheckInfo": "CentralAuthHooks::onSessionCheckInfo",
+               "ImportHandleUnknownUser": 
"CentralAuthHooks::onImportHandleUnknownUser",
                "UnitTestsAfterDatabaseSetup": 
"CentralAuthHooks::onUnitTestsAfterDatabaseSetup",
                "UnitTestsBeforeDatabaseTeardown": 
"CentralAuthHooks::onUnitTestsBeforeDatabaseTeardown"
        },
@@ -437,6 +438,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 019a08a..c363eb6 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -1764,7 +1764,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 );
@@ -1787,7 +1787,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: merged
Gerrit-Change-Id: Ieae5d24f9098c1977447c50a8d4e2cab58a24d9f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Cicalese <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to