r72884 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72883‎ | r72884 | r72885 >
Date:19:28, 12 September 2010
Author:ialex
Status:ok
Tags:
Comment:
Converted CheckUser extension to use DatabaseUpdater
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/CheckUser.php
@@ -338,38 +338,56 @@
339339 return $squidOnly;
340340 }
341341
342 -function efCheckUserSchemaUpdates() {
343 - global $wgDBtype, $wgExtNewIndexes;
 342+function efCheckUserSchemaUpdates( $updater = null ) {
 343+ $base = dirname( __FILE__ );
 344+ if ( $updater === null ) {
 345+ global $wgDBtype, $wgExtNewIndexes;
 346+ efCheckUserCreateTables();
 347+ if ( $wgDBtype == 'mysql' ) {
 348+ $wgExtNewIndexes[] = array(
 349+ 'cu_changes', 'cuc_ip_hex_time',
 350+ "$base/archives/patch-cu_changes_indexes.sql"
 351+ );
 352+ $wgExtNewIndexes[] = array(
 353+ 'cu_changes', 'cuc_user_ip_time',
 354+ "$base/archives/patch-cu_changes_indexes2.sql"
 355+ );
 356+ }
 357+ } else {
 358+ $updater->addExtensionUpdate( array( 'efCheckUserCreateTables' ) );
 359+ if ( $updater->getDB()->getType() == 'mysql' ) {
 360+ $updater->addExtensionUpdate( array( 'addIndex', 'cu_changes',
 361+ 'cuc_ip_hex_time', "$base/archives/patch-cu_changes_indexes.sql", true ) );
 362+ $updater->addExtensionUpdate( array( 'addIndex', 'cu_changes',
 363+ 'cuc_user_ip_time', "$base/archives/patch-cu_changes_indexes2.sql", true ) );
 364+ }
 365+ }
344366
345 - # Run install.inc as necessary
 367+ return true;
 368+}
 369+
 370+function efCheckUserCreateTables( $updater = null ) {
 371+ if ( $updater === null ) {
 372+ $db = wfGetDB( DB_MASTER );
 373+ } else {
 374+ $db = $updater->getDB();
 375+ }
 376+
346377 $base = dirname( __FILE__ );
347378
348 - $db = wfGetDB( DB_MASTER );
349379 if ( $db->tableExists( 'cu_changes' ) ) {
350 - echo "...cu_changes already exists.\n";
 380+ wfOut( "...cu_changes table already exists.\n" );
351381 } else {
352382 require_once "$base/install.inc";
353383 create_cu_changes( $db );
354384 }
355385
356386 if ( $db->tableExists( 'cu_log' ) ) {
357 - echo "...cu_log already exists.\n";
 387+ wfOut( "...cu_log table already exists.\n" );
358388 } else {
359389 require_once "$base/install.inc";
360390 create_cu_log( $db );
361391 }
362 -
363 - if ( $wgDBtype == 'mysql' ) {
364 - $wgExtNewIndexes[] = array(
365 - 'cu_changes', 'cuc_ip_hex_time',
366 - "$base/archives/patch-cu_changes_indexes.sql"
367 - );
368 - $wgExtNewIndexes[] = array(
369 - 'cu_changes', 'cuc_user_ip_time',
370 - "$base/archives/patch-cu_changes_indexes2.sql"
371 - );
372 - }
373 - return true;
374392 }
375393
376394 /**

Status & tagging log