104 for ( $i = count( $indexFields ) - 1; $i >= 0; $i-- ) {
105 $field = $indexFields[$i];
106 $display[] = $field .
'=' . $row->$field;
107 $value = $dbw->addQuotes( $row->$field );
108 if ( $next ===
'' ) {
109 $next =
"$field > $value";
111 $next =
"$field > $value OR $field = $value AND ($next)";
114 $display = implode(
' ', array_reverse( $display ) );
115 return [ $next, $display ];
129 $table, $primaryKey, $idField, $nameField, array $conds, array $orderby
131 if ( $this->table !==
null && $this->table !==
$table ) {
136 if ( !$dbw->fieldExists(
$table, $idField, __METHOD__ ) ||
137 !$dbw->fieldExists(
$table, $nameField, __METHOD__ )
139 $this->
output(
"Skipping $table, fields $idField and/or $nameField do not exist\n" );
143 $primaryKey = (array)$primaryKey;
144 $pkFilter = array_flip( $primaryKey );
145 $this->
output(
"Beginning cleanup of $table\n" );
150 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
155 array_merge( $primaryKey, [ $idField, $nameField ], $orderby ),
156 array_merge( $conds, [ $next ] ),
159 'ORDER BY' => $orderby,
160 'LIMIT' => $this->mBatchSize,
163 if ( !
$res->numRows() ) {
168 foreach (
$res as $row ) {
169 $name = $row->$nameField;
175 if ( $this->assign ) {
179 if ( !isset( $this->triedCreations[$name] ) ) {
180 $this->triedCreations[$name] =
true;
181 if ( !$this->
getHookRunner()->onImportHandleUnknownUser( $name ) ) {
188 $set = [ $idField => $id ];
189 $counter = &$countAssigned;
191 $set = [ $nameField => substr( $this->prefix .
'>' . $name, 0, 255 ) ];
192 $counter = &$countPrefixed;
198 array_intersect_key( (array)$row, $pkFilter ) + [
204 $counter += $dbw->affectedRows();
207 list( $next, $display ) = $this->
makeNextCond( $dbw, $orderby, $row );
208 $this->
output(
"... $display\n" );
209 $lbFactory->waitForReplication();
213 "Completed cleanup, assigned $countAssigned and prefixed $countPrefixed row(s)\n"