From 82b982a4ebe42e98b800d58ec98c307d531d71f9 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Tue, 3 Jun 2014 11:24:31 +0200
Subject: [PATCH] Better unique names for temporary tables

---
 lib/private/db/migrator.php       | 12 +++++++++++-
 lib/private/db/oraclemigrator.php |  8 ++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lib/private/db/migrator.php b/lib/private/db/migrator.php
index 5dd7735dfc6..517be8399e8 100644
--- a/lib/private/db/migrator.php
+++ b/lib/private/db/migrator.php
@@ -77,6 +77,16 @@ class Migrator {
 		}
 	}
 
+	/**
+	 * Create a unique name for the temporary table
+	 *
+	 * @param string $name
+	 * @return string
+	 */
+	protected function generateTemporaryTableName($name) {
+		return 'oc_' . $name . '_' . uniqid();
+	}
+
 	/**
 	 * Check the migration of a table on a copy so we can detect errors before messing with the real table
 	 *
@@ -85,7 +95,7 @@ class Migrator {
 	 */
 	protected function checkTableMigrate(Table $table) {
 		$name = $table->getName();
-		$tmpName = 'oc_' . uniqid();
+		$tmpName = $this->generateTemporaryTableName($name);
 
 		$this->copyTable($name, $tmpName);
 
diff --git a/lib/private/db/oraclemigrator.php b/lib/private/db/oraclemigrator.php
index de4348bd56d..1a8df2def9c 100644
--- a/lib/private/db/oraclemigrator.php
+++ b/lib/private/db/oraclemigrator.php
@@ -29,4 +29,12 @@ class OracleMigrator extends NoCheckMigrator {
 
 		return $schemaDiff;
 	}
+
+	/**
+	 * @param string $name
+	 * @return string
+	 */
+	protected function generateTemporaryTableName($name) {
+		return 'oc_' . uniqid();
+	}
 }
-- 
GitLab