MediaWiki  1.34.0
updateScratchTokenFormat.php
Go to the documentation of this file.
1 <?php
29 
30 if ( getenv( 'MW_INSTALL_PATH' ) ) {
31  $IP = getenv( 'MW_INSTALL_PATH' );
32 } else {
33  $IP = __DIR__ . '/../../..';
34 }
35 require_once "$IP/maintenance/Maintenance.php";
36 
38  public function __construct() {
39  parent::__construct();
40  $this->addDescription( 'Script to update scratch_token column format' );
41  $this->requireExtension( 'OATHAuth' );
42  }
43 
44  public function execute() {
45  global $wgOATHAuthDatabase;
46  $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
47  ->getMainLB( $wgOATHAuthDatabase );
48  $dbw = $lb->getConnectionRef( DB_MASTER, [], $wgOATHAuthDatabase );
49 
50  if ( !UpdateTables::schemaUpdateOldUsers( $dbw ) ) {
51  $this->error( "Failed to update scratch_token rows.\n", 1 );
52  }
53  $this->output( "Done.\n" );
54  }
55 }
56 
57 $maintClass = UpdateScratchTokenFormat::class;
58 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
UpdateScratchTokenFormat\__construct
__construct()
Default constructor.
Definition: updateScratchTokenFormat.php:38
UpdateScratchTokenFormat
Definition: updateScratchTokenFormat.php:37
$IP
$IP
Definition: update.php:3
Maintenance\requireExtension
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
Definition: Maintenance.php:638
MediaWiki\Extension\OATHAuth\Hook\LoadExtensionSchemaUpdates\UpdateTables
Definition: UpdateTables.php:12
DB_MASTER
const DB_MASTER
Definition: defines.php:26
$maintClass
$maintClass
Definition: updateScratchTokenFormat.php:57
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:481
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:453
UpdateScratchTokenFormat\execute
execute()
Do the actual work.
Definition: updateScratchTokenFormat.php:44