[Pkg-owncloud-commits] [owncloud] 24/59: - Added test to trigger index id error - re-enable encryption migration tests - sqlite requires reconnect after schema changes

David Prévot taffit at moszumanska.debian.org
Fri Jul 18 16:19:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 078637130e540a93d59fa9ff6bcad93a1ef70128
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Wed Jun 11 17:02:34 2014 +0200

    - Added test to trigger index id error
    - re-enable encryption migration tests
    - sqlite requires reconnect after schema changes
    
    Backport of 10a2955 from master
---
 apps/files_encryption/tests/migration.php | 43 ++++++++++++++++++++++++++-----
 lib/private/db.php                        | 10 +++++++
 lib/private/db/mdb2schemamanager.php      |  6 +++--
 3 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/apps/files_encryption/tests/migration.php b/apps/files_encryption/tests/migration.php
index d6cd035..e58ceb0 100644
--- a/apps/files_encryption/tests/migration.php
+++ b/apps/files_encryption/tests/migration.php
@@ -50,10 +50,44 @@ class Test_Migration extends PHPUnit_Framework_TestCase {
 
 	}
 
-	public function testDataMigration() {
+	public function checkLastIndexId() {
+		$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
+			.' `item_type`, `item_source`, `item_target`, `share_type`,'
+			.' `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,'
+			.' `file_target`, `token`, `parent`, `expiration`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)');
+		$query->bindValue(1, 'file');
+		$query->bindValue(2, 949);
+		$query->bindValue(3, '/949');
+		$query->bindValue(4, 0);
+		$query->bindValue(5, 'migrate-test-user');
+		$query->bindValue(6, 'migrate-test-owner');
+		$query->bindValue(7, 23);
+		$query->bindValue(8, 1402493312);
+		$query->bindValue(9, 0);
+		$query->bindValue(10, '/migration.txt');
+		$query->bindValue(11, null);
+		$query->bindValue(12, null);
+		$query->bindValue(13, null);
+		$this->assertEquals(1, $query->execute());
+
+		$this->assertNotEquals('0', \OC_DB::insertid('*PREFIX*share'));
+
+		// cleanup
+		$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_target` = ?');
+		$query->bindValue(1, '/migration.txt');
+		$this->assertEquals(1, $query->execute());
+
+	}
+
+	public function testBrokenLastIndexId() {
+
+		// create test table
+		$this->checkLastIndexId();
+		OC_DB::createDbFromStructure(__DIR__ . '/encryption_table.xml');
+		$this->checkLastIndexId();
+	}
 
-		//FIXME fix this test so that we can enable it again
-		$this->markTestIncomplete('Disabled, because of this tests a lot of other tests fail at the moment');
+	public function testDataMigration() {
 
 		$this->assertTableNotExist('encryption_test');
 
@@ -80,9 +114,6 @@ class Test_Migration extends PHPUnit_Framework_TestCase {
 
 	public function testDuplicateDataMigration() {
 
-		//FIXME fix this test so that we can enable it again
-		$this->markTestIncomplete('Disabled, because of this tests a lot of other tests fail at the moment');
-
 		// create test table
 		OC_DB::createDbFromStructure(__DIR__ . '/encryption_table.xml');
 
diff --git a/lib/private/db.php b/lib/private/db.php
index 6aaf31a..221a369 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -106,6 +106,16 @@ class OC_DB {
 	}
 
 	/**
+	 * The existing database connection is closed and connected again
+	 */
+	public static function reconnect() {
+		if(self::$connection) {
+			self::$connection->close();
+			self::$connection->connect();
+		}
+	}
+
+	/**
 	 * @return \OC\DB\Connection
 	 */
 	static public function getConnection() {
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index a6d9e30..d3e379c 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -24,8 +24,6 @@ class MDB2SchemaManager {
 	 */
 	public function __construct($conn) {
 		$this->conn = $conn;
-		$this->conn->close();
-		$this->conn->connect();
 	}
 
 	/**
@@ -150,6 +148,10 @@ class MDB2SchemaManager {
 			$this->conn->query($sql);
 		}
 		$this->conn->commit();
+
+		if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) {
+			\OC_DB::reconnect();
+		}
 		return true;
 	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list