r68326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68325‎ | r68326 | r68327 >
Date:16:15, 20 June 2010
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Fun little script to destroy your wiki
Modified paths:
  • /trunk/phase3/maintenance/nukeEntireWiki.php (added) (history)

Diff [purge]

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
150 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r68333Delete r68326. Too many fixmes and I don't care right now.demon17:54, 20 June 2010

Comments

#Comment by Siebrand (talk | contribs)   17:47, 20 June 2010

Scary script. Maybe a good idea to add an option "--really" before it does what it's supposed to to?

#Comment by MaxSem (talk | contribs)   17:50, 20 June 2010
  1. It nukes all tables, not only those created by MW.
  2. It's not compatible with other databases.

Soooo... It's a FIXME :P

#Comment by Simetrical (talk | contribs)   17:52, 20 June 2010

What real advantage does this have over "DROP DATABASE wikidb;", if the user tables are not nuked?

#Comment by 😂 (talk | contribs)   17:54, 20 June 2010

Fixed all this stuff by deleting the thing.

#Comment by Catrope (talk | contribs)   17:58, 20 June 2010

Could maybe be introduced once we have an abstract schema and therefore can easily identify which tables are MediaWiki's.

Status & tagging log