Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364129 )
Change subject: Break long lines
......................................................................
Break long lines
Change-Id: Ide9ffeecf37036f715e9f82dcd2c435cd64a4527
---
M AntiSpoof/CentralAuthAntiSpoofHooks.php
M CentralAuth.php
M includes/GlobalRename/GlobalRenameUserStatus.php
M includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
M includes/api/ApiQueryGlobalUserInfo.php
M includes/api/ApiQueryWikiSets.php
M maintenance/checkLocalNames.php
M maintenance/checkLocalUser.php
M maintenance/createLocalAccount.php
M maintenance/deleteEmptyAccounts.php
M maintenance/forceRenameUsers.php
M maintenance/migrateAccount.php
M maintenance/migratePass1.php
M maintenance/populateListOfUsersToRename.php
M maintenance/populateLocalAndGlobalIds.php
M maintenance/resetGlobalUserTokens.php
M maintenance/sendConfirmAndMigrateEmail.php
M phpcs.xml
M tests/phpunit/CentralAuthPluginUsingDatabaseTest.php
M tests/phpunit/CentralAuthUserTest.php
20 files changed, 255 insertions(+), 83 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/29/364129/1
diff --git a/AntiSpoof/CentralAuthAntiSpoofHooks.php
b/AntiSpoof/CentralAuthAntiSpoofHooks.php
index b3d0a3d..a2ce69a 100644
--- a/AntiSpoof/CentralAuthAntiSpoofHooks.php
+++ b/AntiSpoof/CentralAuthAntiSpoofHooks.php
@@ -14,7 +14,9 @@
public static function asAbortNewAccountHook( $user, &$message ) {
global $wgAntiSpoofAccounts, $wgUser, $wgRequest;
- $status = self::testNewAccount( $user, $wgUser,
$wgAntiSpoofAccounts, $wgRequest->getCheck( 'wpIgnoreAntiSpoof' ) );
+ $status = self::testNewAccount(
+ $user, $wgUser, $wgAntiSpoofAccounts,
$wgRequest->getCheck( 'wpIgnoreAntiSpoof' )
+ );
if ( !$status->isGood() ) {
$message = Status::wrap( $status
)->getMessage()->escaped();
}
@@ -54,18 +56,23 @@
if ( empty( $conflicts ) ) {
$logger->info( "{$mode}PASS new account '$name'
[$normalized]" );
} else {
- $logger->info( "{$mode}CONFLICT new account
'$name' [$normalized] spoofs " . implode( ',', $conflicts ) );
+ $logger->info( "{$mode}CONFLICT new account
'$name' [$normalized] spoofs " .
+ implode( ',', $conflicts ) );
if ( $active ) {
$numConflicts = count( $conflicts );
// This message pasting-together sucks.
- $message = wfMessage(
'antispoof-conflict-top', $name )->numParams( $numConflicts )->escaped();
+ $message = wfMessage(
'antispoof-conflict-top', $name )
+ ->numParams( $numConflicts
)->escaped();
$message .= '<ul>';
foreach ( $conflicts as $simUser ) {
- $message .= '<li>' . wfMessage(
'antispoof-conflict-item', $simUser )->escaped() . '</li>';
+ $message .= '<li>' .
+ wfMessage(
'antispoof-conflict-item', $simUser )->escaped() . '</li>';
}
$message .= '</ul>' . wfMessage(
'antispoof-conflict-bottom' )->escaped();
- return StatusValue::newFatal( new
RawMessage( '$1', Message::rawParam( $message ) ) );
+ return StatusValue::newFatal(
+ new RawMessage( '$1',
Message::rawParam( $message ) )
+ );
}
}
} else {
diff --git a/CentralAuth.php b/CentralAuth.php
index 426045f..4f927a2 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -5,7 +5,8 @@
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['CentralAuth'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['CentralAuthAlias'] = __DIR__ .
'/CentralAuth.alias.php';
- $wgExtensionMessagesFiles['SpecialCentralAuthAliasesNoTranslate'] =
__DIR__ . '/CentralAuth.notranslate-alias.php';
+ $wgExtensionMessagesFiles['SpecialCentralAuthAliasesNoTranslate'] =
+ __DIR__ . '/CentralAuth.notranslate-alias.php';
// wfWarn(
// 'Deprecated PHP entry point used for CentralAuth extension. ' .
// 'Please use wfLoadExtension instead, ' .
diff --git a/includes/GlobalRename/GlobalRenameUserStatus.php
b/includes/GlobalRename/GlobalRenameUserStatus.php
index 2a9dbf0..6f5d28e 100644
--- a/includes/GlobalRename/GlobalRenameUserStatus.php
+++ b/includes/GlobalRename/GlobalRenameUserStatus.php
@@ -141,7 +141,8 @@
*/
public function updateStatus( $wiki, $status ) {
$dbw = $this->getDB( DB_MASTER );
- $nameWhere = $this->getNameWhereClause( $dbw ); // Can be
inlined easily once we require more than 5.3
+ // Can be inlined easily once we require more than 5.3
+ $nameWhere = $this->getNameWhereClause( $dbw );
$fname = __METHOD__;
$dbw->onTransactionPreCommitOrIdle(
@@ -207,7 +208,8 @@
*/
public function done( $wiki ) {
$dbw = $this->getDB( DB_MASTER );
- $nameWhere = $this->getNameWhereClause( $dbw ); // Can be
inlined easily once we require more than 5.3
+ // Can be inlined easily once we require more than 5.3
+ $nameWhere = $this->getNameWhereClause( $dbw );
$fname = __METHOD__;
$dbw->onTransactionPreCommitOrIdle(
diff --git a/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
b/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
index cb1d1e6..41427fb 100644
--- a/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
+++ b/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
@@ -60,7 +60,8 @@
$user = CentralAuthUser::newFromId( $newId );
foreach ( $attachedWikis as $wiki ) {
$localId = $user->getLocalId( $wiki );
- // Note that $localId will be null in case there is no
local account with new name on that wiki yet
+ // Note that $localId will be null in case there is no
local account with new name
+ // on that wiki yet
$dbw->update(
'localuser',
[ 'lu_local_id' => $localId ],
diff --git a/includes/api/ApiQueryGlobalUserInfo.php
b/includes/api/ApiQueryGlobalUserInfo.php
index fbc713d..2bc0a95 100644
--- a/includes/api/ApiQueryGlobalUserInfo.php
+++ b/includes/api/ApiQueryGlobalUserInfo.php
@@ -46,7 +46,9 @@
$data = [];
$userExists = $user->exists();
- if ( $userExists && ( $user->getHiddenLevel() ===
CentralAuthUser::HIDDEN_NONE || $this->getUser()->isAllowed(
'centralauth-oversight' ) ) ) {
+ if ( $userExists && ( $user->getHiddenLevel() ===
CentralAuthUser::HIDDEN_NONE ||
+ $this->getUser()->isAllowed( 'centralauth-oversight' ) )
+ ) {
// The global user exists and it's not hidden or the
current user is allowed to see it
$data['home'] = $user->getHomeWiki();
$data['id'] = $user->getId();
@@ -96,7 +98,8 @@
];
if ( $account['blocked'] ) {
$a['blocked'] = [
- 'expiry' =>
$this->getLanguage()->formatExpiry( $account['block-expiry'], TS_ISO_8601 ),
+ 'expiry' =>
$this->getLanguage()->formatExpiry(
+
$account['block-expiry'], TS_ISO_8601 ),
'reason' =>
$account['block-reason']
];
}
@@ -121,13 +124,16 @@
];
if ( $account['blocked'] ) {
$a['blocked'] = [
- 'expiry' =>
$this->getLanguage()->formatExpiry( $account['block-expiry'], TS_ISO_8601 ),
+ 'expiry' =>
$this->getLanguage()->formatExpiry(
+
$account['block-expiry'], TS_ISO_8601 ),
'reason' =>
$account['block-reason']
];
}
$result->addValue( [ 'query',
$this->getModuleName(), 'unattached' ], null, $a );
}
- $result->addIndexedTagName( [ 'query',
$this->getModuleName(), 'unattached' ], 'account' );
+ $result->addIndexedTagName(
+ [ 'query', $this->getModuleName(), 'unattached'
], 'account'
+ );
}
}
diff --git a/includes/api/ApiQueryWikiSets.php
b/includes/api/ApiQueryWikiSets.php
index 1068138..d2f2742 100644
--- a/includes/api/ApiQueryWikiSets.php
+++ b/includes/api/ApiQueryWikiSets.php
@@ -45,7 +45,9 @@
/**
* @var $wikiSet WikiSet
*/
- foreach ( WikiSet::getAllWikiSets( $from, $params['limit'],
$params['orderbyname'] ) as $wikiSet ) {
+ foreach (
+ WikiSet::getAllWikiSets( $from, $params['limit'],
$params['orderbyname'] ) as $wikiSet
+ ) {
$entry = [];
$entry['id'] = $wikiSet->getId();
$entry['name'] = $wikiSet->getName();
@@ -62,7 +64,8 @@
}
if ( isset( $prop['wikisnotincluded'] ) ) {
- $entry['wikisnotincluded'] = array_diff(
CentralAuthUser::getWikiList(), $wikiSet->getWikis() );
+ $entry['wikisnotincluded'] = array_diff(
+ CentralAuthUser::getWikiList(),
$wikiSet->getWikis() );
if ( count( $entry['wikisnotincluded'] ) ) {
$APIResult->setIndexedTagName(
$entry['wikisnotincluded'], 'wiki' );
}
diff --git a/maintenance/checkLocalNames.php b/maintenance/checkLocalNames.php
index b6f9b2d..6c7a739 100644
--- a/maintenance/checkLocalNames.php
+++ b/maintenance/checkLocalNames.php
@@ -10,7 +10,8 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->mDescription = "Checks the contents of the localnames
table and deletes invalid entries";
+ $this->mDescription = "Checks the contents of the localnames
table and deletes " .
+ "invalid entries";
$this->start = microtime( true );
$this->deleted = 0;
$this->total = 0;
@@ -19,8 +20,12 @@
$this->verbose = false;
$this->batchSize = 1000;
- $this->addOption( 'delete', 'Performs delete operations on the
offending entries', false, false );
- $this->addOption( 'wiki', 'If specified, only runs against
local names from this wiki', false, true, 'u' );
+ $this->addOption( 'delete',
+ 'Performs delete operations on the offending entries',
false, false
+ );
+ $this->addOption( 'wiki',
+ 'If specified, only runs against local names from this
wiki', false, true, 'u'
+ );
$this->addOption( 'verbose', 'Prints more information', false,
true, 'v' );
}
@@ -100,7 +105,9 @@
// check to see if the user did not
exist in the local user table
if ( $localUser->numRows() == 0 ) {
if ( $this->verbose ) {
- $this->output( "Local
user not found for localname entry $u->ln_name@$wiki\n" );
+ $this->output(
+ "Local user not
found for localname entry $u->ln_name@$wiki\n"
+ );
}
$this->total++;
if ( !$this->dryrun ) {
diff --git a/maintenance/checkLocalUser.php b/maintenance/checkLocalUser.php
index fbd8ac3..fe5ea92 100644
--- a/maintenance/checkLocalUser.php
+++ b/maintenance/checkLocalUser.php
@@ -10,7 +10,8 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->mDescription = "Checks the contents of the localuser
table and deletes invalid entries";
+ $this->mDescription = "Checks the contents of the localuser
table and " .
+ "deletes invalid entries";
$this->start = microtime( true );
$this->deleted = 0;
$this->total = 0;
@@ -20,9 +21,15 @@
$this->verbose = false;
$this->batchSize = 1000;
- $this->addOption( 'delete', 'Performs delete operations on the
offending entries', false, false );
- $this->addOption( 'delete-nowiki', 'Delete entries associated
with invalid wikis', false, false );
- $this->addOption( 'wiki', 'If specified, only runs against
local names from this wiki', false, true, 'u' );
+ $this->addOption( 'delete',
+ 'Performs delete operations on the offending entries',
false, false
+ );
+ $this->addOption( 'delete-nowiki',
+ 'Delete entries associated with invalid wikis', false,
false
+ );
+ $this->addOption( 'wiki',
+ 'If specified, only runs against local names from this
wiki', false, true, 'u'
+ );
$this->addOption( 'allwikis', 'If specified, checks all wikis',
false, false );
$this->addOption( 'user', 'If specified, only checks the given
user', false, true );
$this->addOption( 'verbose', 'Prints more information', false,
true, 'v' );
@@ -71,7 +78,9 @@
$centralMaster->delete(
'localuser', $conds, __METHOD__ );
$this->deleted ++;
} else {
- $this->output( "$wiki does not
exist, use --delete-nowiki to delete entries...\n" );
+ $this->output(
+ "$wiki does not exist,
use --delete-nowiki to delete entries...\n"
+ );
}
} else {
$this->output( "$wiki does not exist\n"
);
@@ -93,7 +102,9 @@
// check to see if the user did not exist in
the local user table
if ( $localUser->numRows() == 0 ) {
if ( $this->verbose ) {
- $this->output( "Local user not
found for localuser entry $username@$wiki\n" );
+ $this->output(
+ "Local user not found
for localuser entry $username@$wiki\n"
+ );
}
$this->total++;
if ( !$this->dryrun ) {
diff --git a/maintenance/createLocalAccount.php
b/maintenance/createLocalAccount.php
index b44ad17..7b82344 100644
--- a/maintenance/createLocalAccount.php
+++ b/maintenance/createLocalAccount.php
@@ -37,7 +37,8 @@
$status = CentralAuthUtils::autoCreateUser( $user );
if ( !$status->isGood() ) {
- $this->error( "autoCreateUser failed for
$username: " . $status->getWikiText( null, null, 'en' ) );
+ $this->error( "autoCreateUser failed for
$username: " .
+ $status->getWikiText( null, null, 'en'
) );
}
# Update user count
diff --git a/maintenance/deleteEmptyAccounts.php
b/maintenance/deleteEmptyAccounts.php
index 58f76ec..d1db1cf 100644
--- a/maintenance/deleteEmptyAccounts.php
+++ b/maintenance/deleteEmptyAccounts.php
@@ -10,16 +10,20 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->mDescription = "Delete all global accounts with no
attached local accounts, then attempt to migrate a local account";
+ $this->mDescription = "Delete all global accounts with no
attached local accounts, " .
+ "then attempt to migrate a local account";
$this->setBatchSize( 500 );
$this->fix = false;
$this->safe = false;
$this->migrate = false;
$this->suppressRC = false;
- $this->addOption( 'fix', 'Actually update the database.
Otherwise, only prints what would be done.', false, false );
- $this->addOption( 'migrate', 'Migrate a local account; the
winner is picked using CentralAuthUser::attemptAutoMigration defaults', false,
false );
- $this->addOption( 'safe-migrate', 'Migrate a local account,
only if all accounts can be attached', false, false );
+ $this->addOption( 'fix', 'Actually update the database.
Otherwise, ' .
+ 'only prints what would be done.', false, false );
+ $this->addOption( 'migrate', 'Migrate a local account; the
winner is picked using ' .
+ 'CentralAuthUser::attemptAutoMigration defaults',
false, false );
+ $this->addOption( 'safe-migrate', 'Migrate a local account,
only if all accounts ' .
+ 'can be attached', false, false );
$this->addOption( 'suppressrc', 'Do not send entries to RC
feed', false, false );
}
@@ -77,7 +81,9 @@
function process( $username ) {
$central = new CentralAuthUser( $username,
CentralAuthUser::READ_LATEST );
if ( !$central->exists() ) {
- $this->output( "ERROR: [$username] Central account does
not exist. So how'd we find it?\n" );
+ $this->output(
+ "ERROR: [$username] Central account does not
exist. So how'd we find it?\n"
+ );
return;
}
@@ -117,7 +123,9 @@
$central = CentralAuthUser::newUnattached(
$username, true );
if ( $central->storeAndMigrate( [],
!$this->suppressRC, $this->safe ) ) {
$unattachedAfter = count(
$central->queryUnattached() );
- $this->output( "MIGRATE: [$username]
Success; $unattachedAfter left unattached\n" );
+ $this->output(
+ "MIGRATE: [$username] Success;
$unattachedAfter left unattached\n"
+ );
} else {
$this->output( "MIGRATE: [$username]
Fail\n" );
}
diff --git a/maintenance/forceRenameUsers.php b/maintenance/forceRenameUsers.php
index 3c532f9..c9c9805 100644
--- a/maintenance/forceRenameUsers.php
+++ b/maintenance/forceRenameUsers.php
@@ -102,7 +102,8 @@
] ] );
if ( !$success ) {
- $this->log( "WARNING: Race condition, renameuser_status
already set for {$newCAUser->getName()}. Skipping." );
+ $this->log( "WARNING: Race condition, renameuser_status
already set for " .
+ "{$newCAUser->getName()}. Skipping." );
return;
}
@@ -135,17 +136,22 @@
protected function findUsers( $wiki, IDatabase $dbw ) {
$rowsToRename = [];
$updates = new UsersToRenameDatabaseUpdates( $dbw );
- $rows = $updates->findUsers( $wiki,
UsersToRenameDatabaseUpdates::NOTIFIED, $this->mBatchSize );
+ $rows = $updates->findUsers(
+ $wiki, UsersToRenameDatabaseUpdates::NOTIFIED,
$this->mBatchSize
+ );
foreach ( $rows as $row ) {
$user = User::newFromName( $row->utr_name );
$caUser = new CentralAuthUser( $row->utr_name,
CentralAuthUser::READ_LATEST );
if ( !$user->getId() ) {
- $this->log( "'{$row->utr_name}' has been
renamed since the last was list generated." );
+ $this->log(
+ "'{$row->utr_name}' has been renamed
since the last was list generated."
+ );
$updates->remove( $row->utr_name,
$row->utr_wiki );
} elseif ( $caUser->attachedOn( $row->utr_wiki ) ) {
- $this->log( "'{$row->utr_name}' has become
attached to a global account since the list as last generated." );
+ $this->log( "'{$row->utr_name}' has become
attached to a global account since " .
+ "the list as last generated." );
$updates->remove( $row->utr_name,
$row->utr_wiki );
} elseif ( !User::isUsableName( $row->utr_name ) ) {
// Reserved for a system account, ignore
diff --git a/maintenance/migrateAccount.php b/maintenance/migrateAccount.php
index 83b53cd..4f265ca 100644
--- a/maintenance/migrateAccount.php
+++ b/maintenance/migrateAccount.php
@@ -10,7 +10,8 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->mDescription = "Migrates the specified usernames to a
global account if email matches and there are no conflicts";
+ $this->mDescription = "Migrates the specified usernames to a
global account if email " .
+ "matches and there are no conflicts";
$this->start = microtime( true );
$this->partial = 0;
$this->migrated = 0;
@@ -22,14 +23,32 @@
$this->resetToken = false;
$this->suppressRC = false;
- $this->addOption( 'auto', 'Extended migration: ALWAYS create a
global account for the username where missing and merge all the local accounts
which match its email; the winner is picked using
CentralAuthUser::attemptAutoMigration defaults, or forced to "homewiki" where
specified by --userlist or --homewiki', false, false );
- $this->addOption( 'userlist', 'List of usernames to migrate in
the format username\thomewiki, where \thomewiki is optional and overrides the
default winner if specified', false, true );
+ $this->addOption( 'auto',
+ 'Extended migration: ALWAYS create a global account for
the username where missing ' .
+ 'and merge all the local accounts which match its
email; the winner is picked using ' .
+ 'CentralAuthUser::attemptAutoMigration defaults, or
forced to "homewiki" where ' .
+ 'specified by --userlist or --homewiki', false, false
+ );
+ $this->addOption( 'userlist',
+ 'List of usernames to migrate in the format
username\thomewiki, where \thomewiki is ' .
+ 'optional and overrides the default winner if
specified', false, true
+ );
$this->addOption( 'username', 'The username to migrate', false,
true, 'u' );
- $this->addOption( 'homewiki', 'The wiki to set as the homewiki.
Can only be used with --username', false, true, 'h' );
- $this->addOption( 'safe', 'Skip usernames used more than once
across all wikis', false, false );
- $this->addOption( 'attachmissing', 'Attach matching local
accounts to an existing global account', false, false );
- $this->addOption( 'attachbroken', 'Attach broken local accounts
to the existing global account', false, false );
- $this->addOption( 'resettoken', 'Allows for the reset of auth
tokens in certain circumstances', false, false );
+ $this->addOption( 'homewiki',
+ 'The wiki to set as the homewiki. Can only be used with
--username', false, true, 'h'
+ );
+ $this->addOption( 'safe',
+ 'Skip usernames used more than once across all wikis',
false, false
+ );
+ $this->addOption( 'attachmissing',
+ 'Attach matching local accounts to an existing global
account', false, false
+ );
+ $this->addOption( 'attachbroken',
+ 'Attach broken local accounts to the existing global
account', false, false
+ );
+ $this->addOption( 'resettoken',
+ 'Allows for the reset of auth tokens in certain
circumstances', false, false
+ );
$this->addOption( 'suppressrc', 'Do not send entries to RC
feed', false, false );
}
@@ -145,7 +164,9 @@
) {
$this->output( "ATTACHING:
$username@$wiki\n" );
// Ironically, the attachment
is made due to lack of a password.
- $central->attach( $wiki,
'password', /** $sendToRC = */ !$this->suppressRC );
+ $central->attach(
+ $wiki, 'password', /**
$sendToRC = */ !$this->suppressRC
+ );
}
}
}
@@ -159,7 +180,9 @@
}
if ( $this->safe && count( $unattached ) !== 1 ) {
- $this->output( "ERROR: More than 1 local user
account found for username: $username\n" );
+ $this->output(
+ "ERROR: More than 1 local user account
found for username: $username\n"
+ );
foreach ( $unattached as $local ) {
$this->output( "\t" .
$central->getName() . "@" . $local['wiki'] . "\n" );
}
@@ -200,7 +223,8 @@
if ( isset( $central->mHomeWiki ) ||
$this->autoMigrate ) {
$central->storeAndMigrate( [],
!$this->suppressRC );
} else {
- $this->output( "ERROR: Auto migration
is disabled and email addresses do not match for: $username\n" );
+ $this->output( "ERROR: Auto migration
is disabled and email addresses do " .
+ "not match for: $username\n" );
}
}
}
@@ -209,7 +233,9 @@
if ( count( $unattachedAfter ) == 0 ) {
$this->migrated++;
return;
- } elseif ( count( $unattachedAfter ) > 0 && count(
$unattachedAfter ) < count( $unattached ) ) {
+ } elseif ( count( $unattachedAfter ) > 0 &&
+ count( $unattachedAfter ) < count( $unattached )
+ ) {
$this->partial++;
$this->output( "INFO: Incomplete migration for
'$username'\n" );
}
@@ -221,7 +247,9 @@
function migratePassOneReport() {
$delta = microtime( true ) - $this->start;
- $this->output( sprintf( "%s processed %d usernames (%.1f/sec),
%d (%.1f%%) fully migrated, %d (%.1f%%) partially migrated\n",
+ $this->output( sprintf(
+ "%s processed %d usernames (%.1f/sec), %d (%.1f%%)
fully migrated, %d (%.1f%%) " .
+ "partially migrated\n",
wfTimestamp( TS_DB ),
$this->total,
$this->total / $delta,
diff --git a/maintenance/migratePass1.php b/maintenance/migratePass1.php
index 8fb9426..bb05795 100644
--- a/maintenance/migratePass1.php
+++ b/maintenance/migratePass1.php
@@ -47,7 +47,8 @@
function migratePassOneReport() {
$delta = microtime( true ) - $this->start;
- $this->output( sprintf( "%s processed %d usernames (%.1f/sec),
%d (%.1f%%) fully migrated (@ %s)\n",
+ $this->output( sprintf(
+ "%s processed %d usernames (%.1f/sec), %d (%.1f%%)
fully migrated (@ %s)\n",
wfTimestamp( TS_DB ),
$this->total,
$this->total / $delta,
diff --git a/maintenance/populateListOfUsersToRename.php
b/maintenance/populateListOfUsersToRename.php
index 6757b43..adf78ba 100644
--- a/maintenance/populateListOfUsersToRename.php
+++ b/maintenance/populateListOfUsersToRename.php
@@ -81,7 +81,8 @@
$attachableWikis[] = $home;
foreach ( $unattached as $wiki
=> $info ) {
if (
$ca->getEmailAuthenticationTimestamp() &&
- $info['email']
=== $ca->getEmail() && !is_null( $info['emailAuthenticated'] )
+ $info['email']
=== $ca->getEmail() &&
+ !is_null(
$info['emailAuthenticated'] )
) {
$attachableWikis[] = $wiki;
}
@@ -89,9 +90,14 @@
} else {
$home = $ca->chooseHomeWiki(
$unattached );
$attachableWikis[] = $home;
- if (
$unattached[$home]['email'] && isset( $unattached[$home]['emailAuthenticated']
) ) {
+ if (
$unattached[$home]['email'] &&
+ isset(
$unattached[$home]['emailAuthenticated'] )
+ ) {
foreach ( $unattached
as $wiki => $info ) {
- if ( $wiki !==
$home && $unattached[$home]['email'] === $info['email'] && isset(
$info['emailAuthenticated'] ) ) {
+ if ( $wiki !==
$home &&
+
$unattached[$home]['email'] === $info['email'] &&
+ isset(
$info['emailAuthenticated'] )
+ ) {
$attachableWikis[] = $wiki;
}
}
diff --git a/maintenance/populateLocalAndGlobalIds.php
b/maintenance/populateLocalAndGlobalIds.php
index 11cf314..7a014e2 100644
--- a/maintenance/populateLocalAndGlobalIds.php
+++ b/maintenance/populateLocalAndGlobalIds.php
@@ -10,7 +10,9 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->addDescription( "Populate the localuser.lu_local_id and
localuser.lu_global_id fields" );
+ $this->addDescription(
+ "Populate the localuser.lu_local_id and
localuser.lu_global_id fields"
+ );
$this->setBatchSize( 1000 );
}
@@ -55,7 +57,9 @@
$globalUidToLocalName = [];
foreach ( $rows as $row ) {
if ( in_array( $row->lu_name,
$globalRenames ) ) {
- $this->output( "User " .
$row->lu_name . " not migrated (pending rename)\n" );
+ $this->output(
+ "User " . $row->lu_name
. " not migrated (pending rename)\n"
+ );
continue;
}
$globalUidToLocalName[$row->gu_id] =
$row->lu_name;
@@ -86,19 +90,24 @@
[ 'lu_name' => $uname,
'lu_wiki' => $wiki ]
);
if ( !$result ) {
- $this->output( "Update failed
for global user $lastGlobalId for wiki $wiki \n" );
+ $this->output(
+ "Update failed for
global user $lastGlobalId for wiki $wiki \n"
+ );
} else {
// Count number of records
actually updated
$updated++;
}
}
- $this->output( "Updated $updated records. Last
user: $lastGlobalId; Wiki: $wiki \n" );
+ $this->output(
+ "Updated $updated records. Last user:
$lastGlobalId; Wiki: $wiki \n"
+ );
CentralAuthUtils::waitForSlaves();
} while ( $numRows >= $this->mBatchSize );
$lb->reuseConnection( $ldbr );
$this->output( "Completed $wiki \n" );
} else {
- $this->error( "This script requires that the
CentralAuth extension is enabled. Please enable it and try again.", 1 );
+ $this->error( "This script requires that the
CentralAuth extension is enabled. " .
+ "Please enable it and try again.", 1 );
}
}
diff --git a/maintenance/resetGlobalUserTokens.php
b/maintenance/resetGlobalUserTokens.php
index 8c7573d..7d281b7 100644
--- a/maintenance/resetGlobalUserTokens.php
+++ b/maintenance/resetGlobalUserTokens.php
@@ -40,20 +40,29 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->mDescription = "Reset the user_token of all users on the
wiki. Note that this may log some of them out.";
+ $this->mDescription = "Reset the user_token of all users on the
wiki. " .
+ "Note that this may log some of them out.";
$this->addOption( 'nowarn', "Hides the 5 seconds warning",
false, false );
$this->addOption( 'minid', "Start processing after this gu_id,
default is 0", false, true );
- $this->addOption( 'maxid', "Stop processing after this gu_id,
default is MAX(gu_id) in globalusers", false, true );
+ $this->addOption( 'maxid', "Stop processing after this gu_id, "
.
+ "default is MAX(gu_id) in globalusers", false, true );
$this->setBatchSize( 1000 );
}
public function execute() {
if ( !$this->getOption( 'nowarn' ) ) {
- $this->output( "The script is about to reset the
user_token for ALL USERS in the database.\n" );
- $this->output( "This may log some of them out and is
not necessary unless you believe your\n" );
+ $this->output(
+ "The script is about to reset the user_token
for ALL USERS in the database.\n"
+ );
+ $this->output(
+ "This may log some of them out and is not
necessary unless you believe your\n"
+ );
$this->output( "user table has been compromised.\n" );
$this->output( "\n" );
- $this->output( "Abort with control-c in the next five
seconds (skip this countdown with --nowarn) ... " );
+ $this->output(
+ "Abort with control-c in the next five seconds
" .
+ "(skip this countdown with --nowarn)
... "
+ );
wfCountDown( 5 );
}
diff --git a/maintenance/sendConfirmAndMigrateEmail.php
b/maintenance/sendConfirmAndMigrateEmail.php
index 6503f1d..4e52436 100644
--- a/maintenance/sendConfirmAndMigrateEmail.php
+++ b/maintenance/sendConfirmAndMigrateEmail.php
@@ -46,7 +46,8 @@
public function __construct() {
parent::__construct();
$this->requireExtension( 'CentralAuth' );
- $this->mDescription = "Resends the 'confirm your email address
email' with a link to Special:MergeAccount";
+ $this->mDescription = "Resends the 'confirm your email address
email' with a link to " .
+ "Special:MergeAccount";
$this->start = microtime( true );
$this->sent = 0;
$this->total = 0;
@@ -55,7 +56,8 @@
$this->addOption( 'userlist', 'List of usernames', false, true
);
$this->addOption( 'username', 'The user name to migrate',
false, true, 'u' );
$this->addOption( 'confirmed', 'Send email to confirmed
accounts', false, false );
- $this->addOption( 'sleep', 'How long to wait in between emails
(default 1 second)', false, true );
+ $this->addOption( 'sleep',
+ 'How long to wait in between emails (default 1
second)', false, true );
$this->addOption( 'dryrun', 'Don\'t actually send any emails',
false, false );
$this->addOption( 'resume', 'Which username to resume after',
false, true );
}
@@ -129,7 +131,9 @@
$user->load();
if ( !$this->sendToConfirmed && $user->isEmailConfirmed() ) {
- $this->output( "ERROR: The user '$username@$wikiID'
already has a confirmed email address\n" );
+ $this->output(
+ "ERROR: The user '$username@$wikiID' already
has a confirmed email address\n"
+ );
return;
}
@@ -160,13 +164,16 @@
$this->sent++;
sleep( $this->sleep );
} else {
- $this->output( "ERROR: Sending confirm and migrate
email failed for '$username@$wikiID'\n" );
+ $this->output(
+ "ERROR: Sending confirm and migrate email
failed for '$username@$wikiID'\n"
+ );
}
}
function report() {
$delta = microtime( true ) - $this->start;
- $this->output( sprintf( "%s: %s processed %d usernames
(%.1f/sec), %d (%.1f%%) emails sent\n",
+ $this->output( sprintf(
+ "%s: %s processed %d usernames (%.1f/sec), %d (%.1f%%)
emails sent\n",
wfWikiID(),
wfTimestamp( TS_DB ),
$this->total,
diff --git a/phpcs.xml b/phpcs.xml
index 35ff078..25af500 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
- <exclude name="Generic.Files.LineLength.TooLong"/>
<exclude
name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName"/>
<exclude
name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment"/>
<exclude name="MediaWiki.Commenting.FunctionComment"/>
</rule>
+ <rule ref="Generic.Files.LineLength">
+ <exclude-pattern>CentralAuth.*alias.php</exclude-pattern>
+ </rule>
<rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
<properties>
<property name="ignoreList" type="array"
value="migratePassZero,getEditCount,countEdits" />
diff --git a/tests/phpunit/CentralAuthPluginUsingDatabaseTest.php
b/tests/phpunit/CentralAuthPluginUsingDatabaseTest.php
index d204090..e8fbc29 100644
--- a/tests/phpunit/CentralAuthPluginUsingDatabaseTest.php
+++ b/tests/phpunit/CentralAuthPluginUsingDatabaseTest.php
@@ -128,11 +128,36 @@
public function provideAuthenticate() {
return [
- [ 'GlobalUser', 'GUP@ssword', true, 'Valid login for
attached global' ],
- [ 'GlobalUser', 'wrongPassword', false, 'Invalid
password for attached global' ],
- [ 'GlobalLockedUser', 'GLUP@ssword', false, 'Valid
password for locked global' ],
- [ 'GlobalUnattachedUser', 'GUUP@ssword', true, 'Valid
password for global but unattached account' ],
- [ 'GlobalConflictUser', 'GCUP@ssword', false, 'Valid
password for global but unattached account, with conflicting local' ],
+ [
+ 'GlobalUser',
+ 'GUP@ssword',
+ true,
+ 'Valid login for attached global'
+ ],
+ [
+ 'GlobalUser',
+ 'wrongPassword',
+ false,
+ 'Invalid password for attached global'
+ ],
+ [
+ 'GlobalLockedUser',
+ 'GLUP@ssword',
+ false,
+ 'Valid password for locked global'
+ ],
+ [
+ 'GlobalUnattachedUser',
+ 'GUUP@ssword',
+ true,
+ 'Valid password for global but unattached
account'
+ ],
+ [
+ 'GlobalConflictUser',
+ 'GCUP@ssword',
+ false,
+ 'Valid password for global but unattached
account, with conflicting local'
+ ],
];
}
@@ -162,7 +187,9 @@
$this->assertSame( false, $user->isAnon(), 'Local account for
GlobalUser exists' ); # sanity
$auth->setPassword( $user, 'ANewPassword' );
$central = new CentralAuthUser( 'GlobalUser',
CentralAuthUser::READ_LATEST );
- $this->assertEquals( 'ok', $central->authenticate(
'ANewPassword' ), 'Authenticate with newly set password' );
+ $this->assertEquals( 'ok', $central->authenticate(
'ANewPassword' ),
+ 'Authenticate with newly set password'
+ );
}
/**
diff --git a/tests/phpunit/CentralAuthUserTest.php
b/tests/phpunit/CentralAuthUserTest.php
index 71d0bdd..28ef781 100644
--- a/tests/phpunit/CentralAuthUserTest.php
+++ b/tests/phpunit/CentralAuthUserTest.php
@@ -56,17 +56,43 @@
return array_intersect_key( $data, [
'attachedMethod' => true ] );
}, $attached )
) );
- $ca->expects( $this->any() )->method( 'queryAttached' )->will(
$this->returnValue( $attached ) );
+ $ca->expects( $this->any() )
+ ->method( 'queryAttached' )
+ ->will( $this->returnValue( $attached ) );
$this->assertEquals( $expected, $ca->getHomeWiki() );
}
public function provideGetHomeWiki() {
return [
- [ [], null ],
- [ [ 'foowiki' => [ 'attachedMethod' => 'new' ] ],
'foowiki' ],
- [ [ 'foowiki' => [ 'attachedMethod' => 'primary' ] ],
'foowiki' ],
- [ [ 'foowiki' => [ 'attachedMethod' => 'password' ],
'bazwiki' => [ 'attachedMethod' => 'new' ] ], 'bazwiki' ],
- [ [ 'foowiki' => [ 'attachedMethod' => 'password' ] ],
'foowiki' ],
+ [
+ [],
+ null
+ ],
+ [
+ [
+ 'foowiki' => [ 'attachedMethod' =>
'new' ]
+ ],
+ 'foowiki'
+ ],
+ [
+ [
+ 'foowiki' => [ 'attachedMethod' =>
'primary' ]
+ ],
+ 'foowiki'
+ ],
+ [
+ [
+ 'foowiki' => [ 'attachedMethod' =>
'password' ],
+ 'bazwiki' => [ 'attachedMethod' =>
'new' ]
+ ],
+ 'bazwiki'
+ ],
+ [
+ [
+ 'foowiki' => [ 'attachedMethod' =>
'password' ]
+ ],
+ 'foowiki'
+ ],
[
[
'foowiki' => [ 'attachedMethod' =>
'primary', 'editCount' => 4 ],
@@ -183,7 +209,9 @@
public static function provideGetPasswordFromString() {
return [
[
-
':pbkdf2:sha256:10000:128:Oin6/F737E41pY7dza46Dw==:f6LNAySaUdEnjI2omuj+CX1aPDnt5bzgZcdLsEcLWqF7vG0CcMyviqWaq8smXCj2HBY0sV/w2kxpsTXXOgUrJJTEjuXmEsxHTtpMO4fCfZ5nb3a1kCYA44owCzKu96i8I6VrmGYu3waxmVAzlXld3bNIxrhGUjra/Y0TmWOe1q0=',
+
':pbkdf2:sha256:10000:128:Oin6/F737E41pY7dza46Dw==:f6LNAySaUdEnjI2omuj+CX1aPDnt5b'
.
+
'zgZcdLsEcLWqF7vG0CcMyviqWaq8smXCj2HBY0sV/w2kxpsTXXOgUrJJTEjuXmEsxHTtpMO4fCfZ' .
+
'5nb3a1kCYA44owCzKu96i8I6VrmGYu3waxmVAzlXld3bNIxrhGUjra/Y0TmWOe1q0=',
'',
'Pbkdf2Password'
],
@@ -210,7 +238,9 @@
->disableOriginalConstructor()
->setMethods( [ 'queryAttached' ] )
->getMock();
- $ca->expects( $this->any() )->method( 'queryAttached' )->will(
$this->returnValue( $attached ) );
+ $ca->expects( $this->any() )
+ ->method( 'queryAttached' )
+ ->will( $this->returnValue( $attached ) );
$this->assertEquals( $expected, $ca->getLocalGroups() );
}
--
To view, visit https://gerrit.wikimedia.org/r/364129
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide9ffeecf37036f715e9f82dcd2c435cd64a4527
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits