Double check its safe before dropping new table during db cloning
authorBrian Wolff <bawolff+wn@gmail.com>
Thu, 22 May 2014 20:44:39 +0000 (17:44 -0300)
committerHashar <hashar@free.fr>
Wed, 25 Jun 2014 10:56:53 +0000 (10:56 +0000)
parserTests.php just killed my user table :(

Bug: 65654
Change-Id: Idcf1c6af6a513c9e6dc650237863db8d61519886

includes/db/CloneDatabase.php

index 3017ea8..9eb3e2f 100644 (file)
@@ -91,6 +91,11 @@ class CloneDatabase {
                        if ( $this->dropCurrentTables
                                && !in_array( $this->db->getType(), array( 'postgres', 'oracle' ) )
                        ) {
+                               if ( $oldTableName === $newTableName ) {
+                                       // Last ditch check to avoid data loss
+                                       throw new MWException( "Not dropping new table, as '$newTableName'"
+                                               . " is name of both the old and the new table." );
+                               }
                                $this->db->dropTable( $tbl, __METHOD__ );
                                wfDebug( __METHOD__ . " dropping {$newTableName}\n" );
                                //Dropping the oldTable because the prefix was changed