3 * Do each user sequentially, since accounts can't be deleted
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @ingroup Maintenance
23 require_once( dirname(__FILE__
) . '/Maintenance.php' );
25 class ConvertUserOptions
extends Maintenance
{
27 private $mConversionCount = 0;
29 public function __construct() {
30 parent
::__construct();
31 $this->mDescription
= "Convert user options from old to new system";
34 public function execute() {
35 $this->output( "Beginning batch conversion of user options.\n" );
37 $dbw = wfGetDB( DB_MASTER
);
39 while ($id !== null) {
40 $idCond = 'user_id>'.$dbw->addQuotes( $id );
41 $optCond = "user_options!=".$dbw->addQuotes( '' ); // For compatibility
42 $res = $dbw->select( 'user', '*',
43 array( $optCond, $idCond ), __METHOD__
,
44 array( 'LIMIT' => 50, 'FOR UPDATE' ) );
45 $id = $this->convertOptionBatch( $res, $dbw );
51 $this->output( "--Converted to ID $id\n" );
53 $this->output( "Conversion done. Converted " . $this->mConversionCount
. " user records.\n" );
56 function convertOptionBatch( $res, $dbw ) {
58 foreach ( $res as $row ) {
59 $this->mConversionCount++
;
61 $u = User
::newFromRow( $row );
71 $maintClass = "ConvertUserOptions";
72 require_once( DO_MAINTENANCE
);