2014-05-19 00:05:59 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Update scratch_token column format
|
|
|
|
*
|
2017-12-09 23:23:07 +00:00
|
|
|
* Usage: php updateScratchTokenFormat.php
|
2014-05-19 00:05:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Darian Anthony Patrick
|
|
|
|
* @ingroup Maintenance
|
|
|
|
*/
|
|
|
|
|
2019-05-14 12:22:36 +00:00
|
|
|
use MediaWiki\Extension\OATHAuth\Hook\LoadExtensionSchemaUpdates\UpdateTables;
|
2020-01-14 08:27:29 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2019-03-14 14:39:10 +00:00
|
|
|
|
2014-05-19 00:05:59 +00:00
|
|
|
if ( getenv( 'MW_INSTALL_PATH' ) ) {
|
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
} else {
|
2017-08-11 04:08:50 +00:00
|
|
|
$IP = __DIR__ . '/../../..';
|
2014-05-19 00:05:59 +00:00
|
|
|
}
|
2016-09-16 23:18:35 +00:00
|
|
|
require_once "$IP/maintenance/Maintenance.php";
|
2014-05-19 00:05:59 +00:00
|
|
|
|
|
|
|
class UpdateScratchTokenFormat extends Maintenance {
|
2018-11-02 10:26:41 +00:00
|
|
|
public function __construct() {
|
2014-05-19 00:05:59 +00:00
|
|
|
parent::__construct();
|
2019-08-19 18:00:48 +00:00
|
|
|
$this->addDescription( 'Script to update scratch_token column format' );
|
2016-12-01 21:17:33 +00:00
|
|
|
$this->requireExtension( 'OATHAuth' );
|
2014-05-19 00:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
2019-03-14 14:39:10 +00:00
|
|
|
global $wgOATHAuthDatabase;
|
|
|
|
$lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
|
|
|
|
->getMainLB( $wgOATHAuthDatabase );
|
|
|
|
$dbw = $lb->getConnectionRef( DB_MASTER, [], $wgOATHAuthDatabase );
|
|
|
|
|
2019-05-14 12:22:36 +00:00
|
|
|
if ( !UpdateTables::schemaUpdateOldUsers( $dbw ) ) {
|
2016-09-16 23:18:35 +00:00
|
|
|
$this->error( "Failed to update scratch_token rows.\n", 1 );
|
2014-05-19 00:05:59 +00:00
|
|
|
}
|
|
|
|
$this->output( "Done.\n" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-03 01:05:56 +00:00
|
|
|
$maintClass = UpdateScratchTokenFormat::class;
|
2016-09-16 23:18:35 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|