103 for ( $i = count( $indexFields ) - 1; $i >= 0; $i-- ) {
104 $field = $indexFields[$i];
105 $display[] = $field .
'=' . $row->$field;
106 $value = $dbw->addQuotes( $row->$field );
107 if ( $next ===
'' ) {
108 $next =
"$field > $value";
110 $next =
"$field > $value OR $field = $value AND ($next)";
113 $display = implode(
' ', array_reverse( $display ) );
114 return [ $next, $display ];
128 $table, $primaryKey, $idField, $nameField, array $conds, array $orderby
130 if ( $this->table !==
null && $this->table !==
$table ) {
135 if ( !$dbw->fieldExists(
$table, $idField ) ||
136 !$dbw->fieldExists(
$table, $nameField )
138 $this->
output(
"Skipping $table, fields $idField and/or $nameField do not exist\n" );
142 $primaryKey = (array)$primaryKey;
143 $pkFilter = array_flip( $primaryKey );
144 $this->
output(
"Beginning cleanup of $table\n" );
153 array_merge( $primaryKey, [ $idField, $nameField ], $orderby ),
154 array_merge( $conds, [ $next ] ),
157 'ORDER BY' => $orderby,
158 'LIMIT' => $this->mBatchSize,
161 if ( !
$res->numRows() ) {
166 foreach (
$res as $row ) {
167 $name = $row->$nameField;
168 if ( $row->$idField || !User::isUsableName( $name ) ) {
173 if ( $this->assign ) {
174 $id = User::idFromName( $name );
177 if ( !isset( $this->triedCreations[$name] ) ) {
178 $this->triedCreations[$name] =
true;
179 if ( !Hooks::run(
'ImportHandleUnknownUser', [ $name ] ) ) {
180 $id = User::idFromName( $name, User::READ_LATEST );
186 $set = [ $idField => $id ];
187 $counter = &$countAssigned;
189 $set = [ $nameField => substr( $this->prefix .
'>' . $name, 0, 255 ) ];
190 $counter = &$countPrefixed;
196 array_intersect_key( (array)$row, $pkFilter ) + [
202 $counter += $dbw->affectedRows();
205 list( $next, $display ) = $this->
makeNextCond( $dbw, $orderby, $row );
206 $this->
output(
"... $display\n" );
211 "Completed cleanup, assigned $countAssigned and prefixed $countPrefixed row(s)\n"