From 8e98f9e3e6c557ad75c9e2b00115e784aa335026 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Thu, 22 May 2014 17:44:39 -0300 Subject: [PATCH] Double check its safe before dropping new table during db cloning parserTests.php just killed my user table :( Bug: 65654 Change-Id: Idcf1c6af6a513c9e6dc650237863db8d61519886 --- includes/db/CloneDatabase.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php index 3017ea809b..9eb3e2fa61 100644 --- a/includes/db/CloneDatabase.php +++ b/includes/db/CloneDatabase.php @@ -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 -- 2.20.1