123 $table, $primaryKey, $idField, $nameField, array $conds, array $orderby
125 if ( $this->table !==
null && $this->table !== $table ) {
130 if ( !$dbw->fieldExists( $table, $idField, __METHOD__ ) ||
131 !$dbw->fieldExists( $table, $nameField, __METHOD__ )
133 $this->
output(
"Skipping $table, fields $idField and/or $nameField do not exist\n" );
137 $primaryKey = (array)$primaryKey;
138 $pkFilter = array_fill_keys( $primaryKey,
true );
139 $this->
output(
"Beginning cleanup of $table\n" );
148 $res = $dbw->newSelectQueryBuilder()
149 ->select( array_merge( $primaryKey, [ $idField, $nameField ], $orderby ) )
151 ->where( array_merge( $conds, [ $next ] ) )
152 ->orderBy( $orderby )
153 ->limit( $this->mBatchSize )
154 ->caller( __METHOD__ )
156 if ( !$res->numRows() ) {
161 foreach ( $res as $row ) {
162 $name = $row->$nameField;
163 if ( $row->$idField || !$userNameUtils->isUsable( $name ) ) {
168 if ( $this->assign ) {
169 $userIdentity = $userIdentityLookup->getUserIdentityByName( $name );
170 if ( !$userIdentity || !$userIdentity->isRegistered() ) {
172 if ( !isset( $this->triedCreations[$name] ) ) {
173 $this->triedCreations[$name] =
true;
174 if ( !$this->
getHookRunner()->onImportHandleUnknownUser( $name ) ) {
175 $userIdentity = $userIdentityLookup
176 ->getUserIdentityByName( $name, IDBAccessObject::READ_LATEST );
177 $id = $userIdentity ? $userIdentity->getId() : 0;
183 $set = [ $idField => $id ];
184 $counter = &$countAssigned;
186 $set = [ $nameField => substr( $this->prefix .
'>' . $name, 0, 255 ) ];
187 $counter = &$countPrefixed;
193 array_intersect_key( (array)$row, $pkFilter ) + [
199 $counter += $dbw->affectedRows();
203 [ $next, $display ] = $this->makeNextCond( $dbw, $orderby, $row );
204 $this->
output(
"... $display\n" );
209 "Completed cleanup, assigned $countAssigned and prefixed $countPrefixed row(s)\n"