比较提交

...

2 次代码提交

作者 SHA1 备注 提交日期
Alexander Vorwerk
6b8bf7ebbd wrapOldPasswordHashes: Fix console output on last batch
also do not give out an output if the result set is empty

Change-Id: I37f08a322a40ca7ed8f286532cedb77626e4ca10
(cherry picked from commit 1be0586281)
2024-05-15 12:09:22 +00:00
Alexander Vorwerk
7252447be2 wrapOldPasswordHashes: Reduce batch size
We are using "LOCK IN SHARE MODE" and since it takes rather long to
migrate a single user (since password hashes are expensive), we
should not look for so long.

Change-Id: I58d683b47851689047235271915924e03244fd2e
(cherry picked from commit 224fcb473a)
2024-05-15 11:55:46 +00:00

查看文件

@ -41,7 +41,7 @@ class WrapOldPasswordHashes extends Maintenance {
'Password type to wrap passwords in (must inherit LayeredParameterizedPassword)', true, true );
$this->addOption( 'verbose', 'Enables verbose output', false, false, 'v' );
$this->addOption( 'update', 'Actually wrap passwords', false, false, 'u' );
$this->setBatchSize( 100 );
$this->setBatchSize( 3 );
$this->requireExtension( 'CentralAuth' );
}
@ -76,7 +76,7 @@ class WrapOldPasswordHashes extends Maintenance {
$count = 0;
$minUserId = 0;
do {
while ( true ) {
if ( $update ) {
$this->beginTransaction( $dbw, __METHOD__ );
}
@ -97,6 +97,13 @@ class WrapOldPasswordHashes extends Maintenance {
]
);
if ( $res->numRows() === 0 ) {
if ( $update ) {
$this->commitTransaction( $dbw, __METHOD__ );
}
break;
}
/** @var CentralAuthUser[] $updateUsers */
$updateUsers = [];
foreach ( $res as $row ) {
@ -132,7 +139,6 @@ class WrapOldPasswordHashes extends Maintenance {
if ( $update ) {
$this->commitTransaction( $dbw, __METHOD__ );
$databaseManager->waitForReplication();
// Clear memcached so old passwords are wiped out
foreach ( $updateUsers as $user ) {
@ -144,11 +150,11 @@ class WrapOldPasswordHashes extends Maintenance {
$delta = microtime( true ) - $start;
$this->output( sprintf(
"%4d passwords wrapped in %6.2fms (%6.2fms each)\n",
$batchSize,
$res->numRows(),
$delta * 1000.0,
( $delta / $batchSize ) * 1000.0
( $delta / $res->numRows() ) * 1000.0
) );
} while ( $res->numRows() );
}
if ( $update ) {
$this->output( "$count users rows updated.\n" );