28 $dir = dirname( dirname( dirname( __DIR__ ) ) );
29 $handler =
new static(
$updater, $dir );
30 return $handler->execute();
43 switch ( $this->updater->getDB()->getType() ) {
46 $this->updater->addExtensionTable(
'oathauth_users',
"{$this->base}/sql/mysql/tables.sql" );
47 $this->updater->addExtensionUpdate( [ [ $this,
'schemaUpdateOldUsersFromInstaller' ] ] );
48 $this->updater->dropExtensionField(
51 "{$this->base}/sql/mysql/patch-remove_reset.sql"
53 $this->updater->addExtensionField(
56 "{$this->base}/sql/mysql/patch-add_generic_fields.sql"
59 $this->updater->addExtensionUpdate(
60 [ [ __CLASS__,
'schemaUpdateSubstituteForGenericFields' ] ]
62 $this->updater->dropExtensionField(
65 "{$this->base}/sql/mysql/patch-remove_module_specific_fields.sql"
68 $this->updater->addExtensionUpdate(
69 [ [ __CLASS__,
'schemaUpdateTOTPToMultipleKeys' ] ]
75 $this->updater->addExtensionTable(
'oathauth_users',
"{$this->base}/sql/oracle/tables.sql" );
79 $this->updater->addExtensionTable(
'oathauth_users',
"{$this->base}/sql/postgres/tables.sql" );
94 global $wgOATHAuthDatabase;
96 ->getMainLB( $wgOATHAuthDatabase );
97 $dbw = $lb->getConnectionRef(
DB_MASTER, [], $wgOATHAuthDatabase );
108 global $wgOATHAuthDatabase;
110 ->getMainLB( $wgOATHAuthDatabase );
111 $dbw = $lb->getConnectionRef(
DB_MASTER, [], $wgOATHAuthDatabase );
122 global $wgOATHAuthDatabase;
124 ->getMainLB( $wgOATHAuthDatabase );
125 $dbw = $lb->getConnectionRef(
DB_MASTER, [], $wgOATHAuthDatabase );
136 if ( !$db->
fieldExists(
'oathauth_users',
'secret' ) ) {
141 $batchSize = $services->getMainConfig()->get(
'UpdateRowsPerQuery' );
142 $lbFactory = $services->getDBLoadBalancerFactory();
144 $lbFactory->waitForReplication();
148 [
'id',
'secret',
'scratch_tokens' ],
155 [
'LIMIT' => $batchSize ]
158 if (
$res->numRows() === 0 ) {
162 foreach (
$res as $row ) {
167 'data' => FormatJson::encode( [
169 'secret' => $row->secret,
170 'scratch_tokens' => $row->scratch_tokens
174 [
'id' => $row->id ],
191 if ( !$db->
fieldExists(
'oathauth_users',
'data' ) ) {
204 foreach (
$res as $row ) {
205 $data = FormatJson::decode( $row->data,
true );
206 if ( isset( $data[
'keys'] ) ) {
212 'data' => FormatJson::encode( [
216 [
'id' => $row->id ],
231 if ( !$db->
fieldExists(
'oathauth_users',
'secret_reset' ) ) {
237 [
'id',
'scratch_tokens' ],
238 [
'is_validated != 0' ],
242 foreach (
$res as $row ) {
243 Wikimedia\suppressWarnings();
244 $scratchTokens =
unserialize( base64_decode( $row->scratch_tokens ) );
245 Wikimedia\restoreWarnings();
246 if ( $scratchTokens ) {
249 [
'scratch_tokens' => implode(
',', $scratchTokens ) ],
250 [
'id' => $row->id ],
257 $db->
delete(
'oathauth_users', [
'is_validated' => 0 ], __METHOD__ );
unserialize( $serialized)
Exceptions for config failures.
Class for handling database updates.