r76216 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76215‎ | r76216 | r76217 >
Date:20:25, 6 November 2010
Author:ialex
Status:deferred
Tags:
Comment:
Converted CreateAccount extension to use the new version of the LoadExtensionSchemaUpdates hook
Modified paths:
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php
@@ -252,34 +252,64 @@
253253 # Status header like "new messages" bar
254254 $wgHooks['SiteNoticeAfter'][] = 'efConfirmAccountsNotice';
255255
256 -function efConfirmAccountSchemaUpdates() {
257 - global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewTables, $wgExtNewIndexes;
 256+function efConfirmAccountSchemaUpdates( $updater = null ) {
258257 $base = dirname( __FILE__ );
259 - if ( $wgDBtype == 'mysql' ) {
260 - $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.sql" );
 258+ if ( $updater === null ) {
 259+ global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewTables, $wgExtNewIndexes;
261260
262 - $wgExtNewFields[] = array( 'account_requests', 'acr_filename',
263 - "$base/archives/patch-acr_filename.sql" );
 261+ if ( $wgDBtype == 'mysql' ) {
 262+ $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.sql" );
264263
265 - $wgExtNewTables[] = array( 'account_credentials', "$base/archives/patch-account_credentials.sql" );
 264+ $wgExtNewFields[] = array( 'account_requests', 'acr_filename',
 265+ "$base/archives/patch-acr_filename.sql" );
266266
267 - $wgExtNewFields[] = array( 'account_requests', 'acr_areas', "$base/archives/patch-acr_areas.sql" );
 267+ $wgExtNewTables[] = array( 'account_credentials', "$base/archives/patch-account_credentials.sql" );
268268
269 - $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/archives/patch-email-index.sql" );
270 - } else if ( $wgDBtype == 'postgres' ) {
271 - $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.pg.sql" );
 269+ $wgExtNewFields[] = array( 'account_requests', 'acr_areas', "$base/archives/patch-acr_areas.sql" );
272270
273 - $wgExtPGNewFields[] = array( 'account_requests', 'acr_held', "TIMESTAMPTZ" );
274 - $wgExtPGNewFields[] = array( 'account_requests', 'acr_filename', "TEXT" );
275 - $wgExtPGNewFields[] = array( 'account_requests', 'acr_storage_key', "TEXT" );
276 - $wgExtPGNewFields[] = array( 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''" );
 271+ $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/archives/patch-email-index.sql" );
 272+ } else if ( $wgDBtype == 'postgres' ) {
 273+ $wgExtNewTables[] = array( 'account_requests', "$base/ConfirmAccount.pg.sql" );
277274
278 - $wgExtPGNewFields[] = array( 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0" );
279 - $wgExtNewTables[] = array( 'account_credentials', "$base/postgres/patch-account_credentials.sql" );
280 - $wgExtPGNewFields[] = array( 'account_requests', 'acr_areas', "TEXT" );
281 - $wgExtPGNewFields[] = array( 'account_credentials', 'acd_areas', "TEXT" );
 275+ $wgExtPGNewFields[] = array( 'account_requests', 'acr_held', "TIMESTAMPTZ" );
 276+ $wgExtPGNewFields[] = array( 'account_requests', 'acr_filename', "TEXT" );
 277+ $wgExtPGNewFields[] = array( 'account_requests', 'acr_storage_key', "TEXT" );
 278+ $wgExtPGNewFields[] = array( 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''" );
282279
283 - $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/postgres/patch-email-index.sql" );
 280+ $wgExtPGNewFields[] = array( 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0" );
 281+ $wgExtNewTables[] = array( 'account_credentials', "$base/postgres/patch-account_credentials.sql" );
 282+ $wgExtPGNewFields[] = array( 'account_requests', 'acr_areas', "TEXT" );
 283+ $wgExtPGNewFields[] = array( 'account_credentials', 'acd_areas', "TEXT" );
 284+
 285+ $wgExtNewIndexes[] = array( 'account_requests', 'acr_email', "$base/postgres/patch-email-index.sql" );
 286+ }
 287+ } else {
 288+ if ( $updater->getDB()->getType() == 'mysql' ) {
 289+ $updater->addExtensionUpdate( array( 'addTable', 'account_requests', "$base/ConfirmAccount.sql", true ) );
 290+
 291+ $updater->addExtensionUpdate( array( 'addField', 'account_requests', 'acr_filename',
 292+ "$base/archives/patch-acr_filename.sql", true ) );
 293+
 294+ $updater->addExtensionUpdate( array( 'addTable', 'account_credentials', "$base/archives/patch-account_credentials.sql", true ) );
 295+
 296+ $updater->addExtensionUpdate( array( 'addField', 'account_requests', 'acr_areas', "$base/archives/patch-acr_areas.sql", true ) );
 297+
 298+ $updater->addExtensionUpdate( array( 'addIndex', 'account_requests', 'acr_email', "$base/archives/patch-email-index.sql", true ) );
 299+ } else if ( $updater->getDB()->getType() == 'postgres' ) {
 300+ $updater->addExtensionUpdate( array( 'addTable', 'account_requests', "$base/ConfirmAccount.pg.sql", true );
 301+
 302+ $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_held', "TIMESTAMPTZ" ) );
 303+ $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_filename', "TEXT" ) );
 304+ $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_storage_key', "TEXT" ) );
 305+ $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_comment', "TEXT NOT NULL DEFAULT ''" ) );
 306+
 307+ $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_type', "INTEGER NOT NULL DEFAULT 0" ) );
 308+ $updater->addExtensionUpdate( array( 'addTable', 'account_credentials', "$base/postgres/patch-account_credentials.sql", true ) );
 309+ $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_areas', "TEXT" ) );
 310+ $updater->addExtensionUpdate( array( 'addPgField', 'account_credentials', 'acd_areas', "TEXT" ) );
 311+
 312+ $updater->addExtensionUpdate( array( 'addIndex', 'account_requests', 'acr_email', "$base/postgres/patch-email-index.sql", true ) );
 313+ }
284314 }
285315 return true;
286316 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r76217*faceplam* Fixed fatal error from r76216ialex20:28, 6 November 2010

Status & tagging log