Remove unused 'cachederror' and 'loginpagetitle'
[lhc/web/wiklou.git] / maintenance / convertUserOptions.php
1 <?php
2 require( './commandLine.inc' );
3
4 // Do each user sequentially, since accounts can't be deleted
5
6 print "Beginning batch conversion of user options.\n";
7
8 $id = 0;
9 $dbw = wfGetDB( DB_MASTER );
10 $conversionCount = 0;
11
12 while ($id !== null) {
13 $idCond = 'user_id>'.$dbw->addQuotes( $id );
14 $optCond = "user_options!=".$dbw->addQuotes( '' ); // For compatibility
15 $res = $dbw->select( 'user', '*',
16 array( $optCond, $idCond ), __METHOD__,
17 array( 'LIMIT' => 50, 'FOR UPDATE' ) );
18 $id = convertOptionBatch( $res, $dbw );
19 $dbw->commit();
20
21 wfWaitForSlaves( 1 );
22
23 if ($id)
24 print "--Converted to ID $id\n";
25 }
26 print "Conversion done. Converted $conversionCount user records.\n";
27
28 function convertOptionBatch( $res, $dbw ) {
29 $id = null;
30 while ($row = $dbw->fetchObject( $res ) ) {
31 global $conversionCount;
32 $conversionCount++;
33
34 $u = User::newFromRow( $row );
35
36 $u->saveSettings();
37 $id = $row->user_id;
38 }
39
40 return $id;
41 }