Index: trunk/phase3/maintenance/nukeEntireWiki.php |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +<?php |
| 3 | +/* |
| 4 | + * This script is designed to destroy your entire wiki so you can start over. |
| 5 | + * THIS IS NOT RECOVERABLE IN ANY WAY SHAPE OR FORM. You have been warned. |
| 6 | + * |
| 7 | + * @ingroup Maintenance |
| 8 | + */ |
| 9 | + |
| 10 | +require_once( 'Maintenance.php' ); |
| 11 | + |
| 12 | +class NukeEntireWiki extends Maintenance { |
| 13 | + |
| 14 | + public function __construct() { |
| 15 | + parent::__construct(); |
| 16 | + $this->mDescription = "Truncate all tables in your wiki. Skips user-related tables by default"; |
| 17 | + $this->addOption( 'users', 'Include the user-related tables' ); |
| 18 | + } |
| 19 | + |
| 20 | + public function getDbType() { |
| 21 | + return Maintenance::DB_ADMIN; |
| 22 | + } |
| 23 | + |
| 24 | + public function execute() { |
| 25 | + $this->output( "This will truncate all tables in your MediaWiki installation. Press Ctrl+C to abort\n" ); |
| 26 | + wfCountDown( 5 ); |
| 27 | + |
| 28 | + $dbw = wfGetDB( DB_MASTER ); |
| 29 | + |
| 30 | + // Skip these tables unless the --users switch was given |
| 31 | + if( !$this->hasOption( 'users' ) ) { |
| 32 | + $userTables = $dbw->tableNamesN( 'user', 'user_groups', 'user_properties' ); |
| 33 | + } else { |
| 34 | + $userTables = array(); |
| 35 | + } |
| 36 | + |
| 37 | + $res = $dbw->query( "SHOW TABLES" ); |
| 38 | + while( $tbl = $dbw->fetchRow( $res ) ) { |
| 39 | + if( in_array( "`{$tbl[0]}`", $userTables ) ) |
| 40 | + continue; |
| 41 | + $this->output( "Truncating table {$tbl[0]}..." ); |
| 42 | + $dbw->query( "TRUNCATE TABLE {$tbl[0]}" ); |
| 43 | + $this->output( "done\n" ); |
| 44 | + } |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +$maintClass = 'NukeEntireWiki'; |
| 49 | +require_once( DO_MAINTENANCE ); |
Property changes on: trunk/phase3/maintenance/nukeEntireWiki.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 50 | + native |