Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -153,7 +153,10 @@ |
154 | 154 | 'gu_email' => $email, |
155 | 155 | 'gu_email_authenticated' => $emailAuth, |
156 | 156 | ), |
157 | | - __METHOD__ ); |
| 157 | + __METHOD__, |
| 158 | + array( 'IGNORE' ) ); |
| 159 | + |
| 160 | + return $dbw->affectedRows() != 0; |
158 | 161 | } |
159 | 162 | |
160 | 163 | function storeAndMigrate() { |
— | — | @@ -220,7 +223,19 @@ |
221 | 224 | // the conflicting password or deal with the conflict. |
222 | 225 | } |
223 | 226 | } |
| 227 | + |
| 228 | + $ok = $this->storeGlobalData( |
| 229 | + $winner->lu_local_id, |
| 230 | + $winner->lu_migrated_password, |
| 231 | + $winner->lu_migrated_email, |
| 232 | + $winner->lu_migrated_email_authenticated ); |
224 | 233 | |
| 234 | + if( !$ok ) { |
| 235 | + wfDebugLog( 'CentralAuth', |
| 236 | + "attemptedAutoMigration for existing entry '$this->mName'" ); |
| 237 | + return false; |
| 238 | + } |
| 239 | + |
225 | 240 | if( count( $attach ) < count( $rows ) ) { |
226 | 241 | wfDebugLog( 'CentralAuth', |
227 | 242 | "Incomplete migration for '$this->mName'" ); |
— | — | @@ -233,12 +248,6 @@ |
234 | 249 | "Full automatic migration for '$this->mName'" ); |
235 | 250 | } |
236 | 251 | } |
237 | | - |
238 | | - $this->storeGlobalData( |
239 | | - $winner->lu_local_id, |
240 | | - $winner->lu_migrated_password, |
241 | | - $winner->lu_migrated_email, |
242 | | - $winner->lu_migrated_email_authenticated ); |
243 | 252 | |
244 | 253 | foreach( $attach as $dbname => $method ) { |
245 | 254 | $this->attach( $dbname, $method ); |
Index: trunk/extensions/CentralAuth/migratePass1.php |
— | — | @@ -6,6 +6,11 @@ |
7 | 7 | require dirname(__FILE__) . '/../../maintenance/commandLine.inc'; |
8 | 8 | |
9 | 9 | function migratePassOne() { |
| 10 | + $migrated = 0; |
| 11 | + $total = 0; |
| 12 | + $chunkSize = 1000; |
| 13 | + $start = microtime( true ); |
| 14 | + |
10 | 15 | $dbBackground = wfGetDB( DB_SLAVE, 'CentralAuth' ); // fixme for large dbs |
11 | 16 | $result = $dbBackground->select( |
12 | 17 | CentralAuthUser::tableName( 'localuser' ), |
— | — | @@ -17,14 +22,28 @@ |
18 | 23 | $name = $row->lu_migrated_name; |
19 | 24 | $central = new CentralAuthUser( $name ); |
20 | 25 | if( $central->storeAndMigrate() ) { |
21 | | - echo "Migrated '$name'\n"; |
22 | | - } else { |
23 | | - echo "Incomplete '$name'\n"; |
| 26 | + $migrated++; |
24 | 27 | } |
| 28 | + if( ++$total % $chunkSize == 0 ) { |
| 29 | + migratePassOneReport( $migrated, $total, $start ); |
| 30 | + } |
25 | 31 | } |
26 | 32 | $dbBackground->freeResult( $result ); |
| 33 | + migratePassOneReport( $migrated, $total, $start ); |
| 34 | + echo "DONE\n"; |
27 | 35 | } |
28 | 36 | |
| 37 | +function migratePassOneReport( $migrated, $total, $start ) { |
| 38 | + $delta = microtime( true ) - $start; |
| 39 | + printf( "%s processed %d usernames (%.1f/sec), %d (%.1f%%) fully migrated\n", |
| 40 | + wfTimestamp( TS_DB ), |
| 41 | + $total, |
| 42 | + $total / $delta, |
| 43 | + $migrated, |
| 44 | + $migrated / $total * 100.0 ); |
| 45 | + |
| 46 | +} |
| 47 | + |
29 | 48 | if( $wgCentralAuthState != 'pass1' ) { |
30 | 49 | if( $wgCentralAuthState == 'testing' ) { |
31 | 50 | echo "WARNING: \$wgCentralAuthState is set to 'testing', generated data may be corrupt.\n"; |