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
21 * @ingroup Maintenance
24 require_once( dirname( __FILE__
) . '/Maintenance.php' );
26 class ConvertUserOptions
extends Maintenance
{
28 private $mConversionCount = 0;
30 public function __construct() {
31 parent
::__construct();
32 $this->mDescription
= "Convert user options from old to new system";
35 public function execute() {
36 $this->output( "Beginning batch conversion of user options.\n" );
38 $dbw = wfGetDB( DB_MASTER
);
40 while ( $id !== null ) {
41 $idCond = 'user_id>' . $dbw->addQuotes( $id );
42 $optCond = "user_options!=" . $dbw->addQuotes( '' ); // For compatibility
43 $res = $dbw->select( 'user', '*',
44 array( $optCond, $idCond ), __METHOD__
,
45 array( 'LIMIT' => 50, 'FOR UPDATE' ) );
46 $id = $this->convertOptionBatch( $res, $dbw );
52 $this->output( "--Converted to ID $id\n" );
54 $this->output( "Conversion done. Converted " . $this->mConversionCount
. " user records.\n" );
57 function convertOptionBatch( $res, $dbw ) {
59 foreach ( $res as $row ) {
60 $this->mConversionCount++
;
62 $u = User
::newFromRow( $row );
72 $maintClass = "ConvertUserOptions";
73 require_once( DO_MAINTENANCE
);