MediaWiki
master
Toggle main menu visibility
fixWrongPasswordPrefixes.php
Go to the documentation of this file.
1
<?php
7
8
use
MediaWiki\Maintenance\LoggedUpdateMaintenance
;
9
use
MediaWiki\Maintenance\LoggedUpdateOutcome
;
10
use
Wikimedia\Rdbms\IExpression
;
11
use
Wikimedia\Rdbms\LikeValue
;
12
13
// @codeCoverageIgnoreStart
14
require_once __DIR__ .
'/Maintenance.php'
;
15
// @codeCoverageIgnoreEnd
16
24
class
FixWrongPasswordPrefixes
extends
LoggedUpdateMaintenance
{
25
public
function
__construct
() {
26
parent::__construct();
27
$this->
setBatchSize
( 100 );
28
}
29
31
protected
function
getUpdateKey
() {
32
return
__CLASS__;
33
}
34
36
protected
function
doDBUpdates
():
LoggedUpdateOutcome
{
37
$dbw = $this->
getPrimaryDB
();
38
$batchSize = $this->
getBatchSize
();
39
$minUserId = 0;
40
41
while
(
true
) {
42
$res = $dbw->newSelectQueryBuilder()
43
->select( [
'user_id'
,
'user_password'
] )
44
->from(
'user'
)
45
->where( $dbw->expr(
'user_id'
,
'>'
, $minUserId ) )
46
->andWhere(
47
$dbw->expr(
'user_password'
,
IExpression::LIKE
,
new
LikeValue
(
':A:'
, $dbw->anyString() ) )
48
)
49
->orderBy(
'user_id'
)
50
->limit( $batchSize )
51
->caller( __METHOD__ )
52
->fetchResultSet();
53
54
if
( $res->numRows() === 0 ) {
55
break
;
56
}
57
58
foreach
( $res as $row ) {
59
$passwordHash = substr( $row->user_password, 3 );
60
if
( strpos( $passwordHash,
':'
) > 0 ) {
61
$dbw->newUpdateQueryBuilder()
62
->update(
'user'
)
63
->set( [
'user_password'
=>
':B:'
. $passwordHash ] )
64
->where( [
'user_id'
=> $row->user_id ] )
65
->caller( __METHOD__ )
66
->execute();
67
}
68
69
$minUserId = $row->user_id;
70
}
71
}
72
73
$this->
output
(
"Wrongly prefixed user password hashes, if present, have been fixed.\n"
);
74
return
LoggedUpdateOutcome::COMPLETE;
75
}
76
}
77
78
// @codeCoverageIgnoreStart
79
$maintClass
= FixWrongPasswordPrefixes::class;
80
require_once RUN_MAINTENANCE_IF_MAIN;
81
// @codeCoverageIgnoreEnd
$maintClass
$maintClass
Definition
addChangeTag.php:56
FixWrongPasswordPrefixes
An error in a previous version of MediaWiki caused B type passwords to be written with an :A: prefix ...
Definition
fixWrongPasswordPrefixes.php:24
FixWrongPasswordPrefixes\__construct
__construct()
Default constructor.
Definition
fixWrongPasswordPrefixes.php:25
FixWrongPasswordPrefixes\getUpdateKey
getUpdateKey()
Get the update key name to go in the update log table.string
Definition
fixWrongPasswordPrefixes.php:31
FixWrongPasswordPrefixes\doDBUpdates
doDBUpdates()
Do the actual work.All child classes will need to implement this.LoggedUpdateOutcome|bool The outcome...
Definition
fixWrongPasswordPrefixes.php:36
MediaWiki\Maintenance\LoggedUpdateMaintenance
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Definition
LoggedUpdateMaintenance.php:14
MediaWiki\Maintenance\Maintenance\setBatchSize
setBatchSize( $s=0)
Definition
Maintenance.php:425
MediaWiki\Maintenance\Maintenance\getBatchSize
getBatchSize()
Returns batch size.
Definition
Maintenance.php:418
MediaWiki\Maintenance\Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition
Maintenance.php:485
MediaWiki\Maintenance\Maintenance\getPrimaryDB
getPrimaryDB(string|false $virtualDomain=false)
Definition
Maintenance.php:1143
Wikimedia\Rdbms\LikeValue
Content of like value.
Definition
LikeValue.php:14
Wikimedia\Rdbms\IExpression
Definition
IExpression.php:10
Wikimedia\Rdbms\IExpression\LIKE
const LIKE
Definition
IExpression.php:14
MediaWiki\Maintenance\LoggedUpdateOutcome
LoggedUpdateOutcome
Enum representing the outcome of LoggedUpdateMaintenance\doDbUpdates().
Definition
LoggedUpdateOutcome.php:12
maintenance
fixWrongPasswordPrefixes.php
Generated on
for MediaWiki by
1.18.0