MediaWiki REL1_34
updateTOTPToMultipleKeys.php
Go to the documentation of this file.
1<?php
29
30if ( getenv( 'MW_INSTALL_PATH' ) ) {
31 $IP = getenv( 'MW_INSTALL_PATH' );
32} else {
33 $IP = __DIR__ . '/../../..';
34}
35require_once "$IP/maintenance/Maintenance.php";
36
38 public function __construct() {
39 parent::__construct();
40 $this->addDescription( 'Script to update single TOTP keys to multi-key environment' );
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::switchTOTPToMultipleKeys( $dbw ) ) {
51 $this->error( "Failed to update TOTP keys.\n", 1 );
52 }
53 $this->output( "Done.\n" );
54 }
55}
56
57$maintClass = UpdateTOTPToMultipleKeys::class;
58require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
MediaWikiServices is the service locator for the application scope of MediaWiki.
$IP
Definition update.php:3
const DB_MASTER
Definition defines.php:26