jenkins-bot has submitted this change and it was merged.

Change subject: Add ignoretitleblacklist to account creation API
......................................................................


Add ignoretitleblacklist to account creation API

Bug: T109517
Change-Id: Ie4d879f692cddc47d730d9aee9a9a534e9d22937
---
M TitleBlacklist.hooks.php
M extension.json
M i18n/en.json
M i18n/qqq.json
4 files changed, 48 insertions(+), 2 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  Siebrand: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/TitleBlacklist.hooks.php b/TitleBlacklist.hooks.php
index 40466ea..2155223 100644
--- a/TitleBlacklist.hooks.php
+++ b/TitleBlacklist.hooks.php
@@ -247,6 +247,44 @@
        }
 
        /**
+        * @param ApiBase $module
+        * @param array $params
+        * @return bool
+        */
+       public static function onAPIGetAllowedParams( ApiBase &$module, array 
&$params ) {
+               if ( $module instanceof ApiCreateAccount ) {
+                       $params['ignoretitleblacklist'] = array(
+                               ApiBase::PARAM_TYPE => 'boolean',
+                               ApiBase::PARAM_DFLT => false
+                       );
+               }
+
+               return true;
+       }
+
+       /**
+        * Pass API parameter on to the login form when using
+        * API account creation.
+        *
+        * @param ApiBase $apiModule
+        * @param LoginForm $loginForm
+        * @return bool Always true
+        */
+       public static function onAddNewAccountApiForm( ApiBase $apiModule, 
LoginForm $loginForm ) {
+               global $wgRequest;
+               $main = $apiModule->getMain();
+
+               if ( $main->getVal( 'ignoretitleblacklist' ) !== null ) {
+                       $wgRequest->setVal( 'wpIgnoreTitleBlacklist', '1' );
+
+                       // Suppress "unrecognized parameter" warning:
+                       $main->getVal( 'wpIgnoreTitleBlacklist' );
+               }
+
+               return true;
+       }
+
+       /**
         * Logs the filter username hit to Special:Log if
         * $wgTitleBlacklistLogHits is enabled.
         *
diff --git a/extension.json b/extension.json
index e5b9ed6..3d1adca 100644
--- a/extension.json
+++ b/extension.json
@@ -89,6 +89,12 @@
                ],
                "ScribuntoExternalLibraries": [
                        "TitleBlacklistHooks::scribuntoExternalLibraries"
+               ],
+               "APIGetAllowedParams": [
+                       "TitleBlacklistHooks::onAPIGetAllowedParams"
+               ],
+               "AddNewAccountApiForm": [
+                       "TitleBlacklistHooks::onAddNewAccountApiForm"
                ]
        },
        "config": {
diff --git a/i18n/en.json b/i18n/en.json
index a7efd2a..837ac8f 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -25,5 +25,6 @@
        "apihelp-titleblacklist-param-action": "The action to be checked.",
        "apihelp-titleblacklist-param-nooverride": "Don't try to override the 
titleblacklist.",
        "apihelp-titleblacklist-example-1": "Check whether [[Foo]] is 
blacklisted",
-       "apihelp-titleblacklist-example-2": "Check whether [[Bar]] is 
blacklisted for editing"
+       "apihelp-titleblacklist-example-2": "Check whether [[Bar]] is 
blacklisted for editing",
+       "apihelp-createaccount-param-ignoretitleblacklist": "Ignore spoofing 
checks (requires one of the following rights: <code>tboverride</code>, 
<code>tboverride-account</code>)."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 345e2e6..97adcbf 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -34,5 +34,6 @@
        "apihelp-titleblacklist-param-action": 
"{{doc-apihelp-param|titleblacklist|action}}",
        "apihelp-titleblacklist-param-nooverride": 
"{{doc-apihelp-param|titleblacklist|nooverride}}",
        "apihelp-titleblacklist-example-1": 
"{{doc-apihelp-example|titleblacklist}}",
-       "apihelp-titleblacklist-example-2": "Replace \"Bar\" with any example 
string suitable for your language, for instance the translation of 
\"Example\".\n----\n{{doc-apihelp-example|titleblacklist}}"
+       "apihelp-titleblacklist-example-2": "Replace \"Bar\" with any example 
string suitable for your language, for instance the translation of 
\"Example\".\n----\n{{doc-apihelp-example|titleblacklist}}",
+       "apihelp-createaccount-param-ignoretitleblacklist": 
"{{doc-apihelp-param|createaccount|ignoretitleblacklist}}"
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie4d879f692cddc47d730d9aee9a9a534e9d22937
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/TitleBlacklist
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to