From 25a735231cd2831b4ade2463111da4c67aae60e4 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 20 Jun 2010 16:15:00 +0000 Subject: [PATCH] Fun little script to destroy your wiki --- maintenance/nukeEntireWiki.php | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 maintenance/nukeEntireWiki.php diff --git a/maintenance/nukeEntireWiki.php b/maintenance/nukeEntireWiki.php new file mode 100644 index 0000000000..8f0f084fa9 --- /dev/null +++ b/maintenance/nukeEntireWiki.php @@ -0,0 +1,48 @@ +mDescription = "Truncate all tables in your wiki. Skips user-related tables by default"; + $this->addOption( 'users', 'Include the user-related tables' ); + } + + public function getDbType() { + return Maintenance::DB_ADMIN; + } + + public function execute() { + $this->output( "This will truncate all tables in your MediaWiki installation. Press Ctrl+C to abort\n" ); + wfCountDown( 5 ); + + $dbw = wfGetDB( DB_MASTER ); + + // Skip these tables unless the --users switch was given + if( !$this->hasOption( 'users' ) ) { + $userTables = $dbw->tableNamesN( 'user', 'user_groups', 'user_properties' ); + } else { + $userTables = array(); + } + + $res = $dbw->query( "SHOW TABLES" ); + while( $tbl = $dbw->fetchRow( $res ) ) { + if( in_array( "`{$tbl[0]}`", $userTables ) ) + continue; + $this->output( "Truncating table {$tbl[0]}..." ); + $dbw->query( "TRUNCATE TABLE {$tbl[0]}" ); + $this->output( "done\n" ); + } + } +} + +$maintClass = 'NukeEntireWiki'; +require_once( DO_MAINTENANCE ); -- 2.20.1