MediaWiki  1.34.0
updateDatabaseValueFormat.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 convert old, TOTP specific, column values to new structure' );
41  $this->requireExtension( 'OATHAuth' );
42  }
43 
47  public function execute() {
48  global $wgOATHAuthDatabase;
49  $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
50  ->getMainLB( $wgOATHAuthDatabase );
51  $dbw = $lb->getConnectionRef( DB_MASTER, [], $wgOATHAuthDatabase );
52 
53  if ( !UpdateTables::convertToGenericFields( $dbw ) ) {
54  $this->error( "Failed to update the data structure rows.\n", 1 );
55  }
56  $this->output( "Done.\n" );
57  }
58 }
59 
60 $maintClass = UpdateDatabaseValueFormat::class;
61 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
UpdateDatabaseValueFormat\__construct
__construct()
Default constructor.
Definition: updateDatabaseValueFormat.php:38
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
$maintClass
$maintClass
Definition: updateDatabaseValueFormat.php:60
UpdateDatabaseValueFormat\execute
execute()
Definition: updateDatabaseValueFormat.php:47
$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
UpdateDatabaseValueFormat
Definition: updateDatabaseValueFormat.php:37
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