Index: trunk/extensions/CheckUser/CheckUser.php |
— | — | @@ -338,38 +338,56 @@ |
339 | 339 | return $squidOnly; |
340 | 340 | } |
341 | 341 | |
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 | + } |
344 | 366 | |
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 | + |
346 | 377 | $base = dirname( __FILE__ ); |
347 | 378 | |
348 | | - $db = wfGetDB( DB_MASTER ); |
349 | 379 | if ( $db->tableExists( 'cu_changes' ) ) { |
350 | | - echo "...cu_changes already exists.\n"; |
| 380 | + wfOut( "...cu_changes table already exists.\n" ); |
351 | 381 | } else { |
352 | 382 | require_once "$base/install.inc"; |
353 | 383 | create_cu_changes( $db ); |
354 | 384 | } |
355 | 385 | |
356 | 386 | if ( $db->tableExists( 'cu_log' ) ) { |
357 | | - echo "...cu_log already exists.\n"; |
| 387 | + wfOut( "...cu_log table already exists.\n" ); |
358 | 388 | } else { |
359 | 389 | require_once "$base/install.inc"; |
360 | 390 | create_cu_log( $db ); |
361 | 391 | } |
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; |
374 | 392 | } |
375 | 393 | |
376 | 394 | /** |