From e55d2359b1746e29b764a0d366afbb857b797341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 17 Oct 2013 14:54:37 +0200 Subject: [PATCH 1/2] removing pointless calls on quoteIdentifier() - reason: name on $tableDiff doesn't exist and my design the name cannot be changed adding PHPDoc --- lib/private/db/mdb2schemamanager.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index fc13e881bf..8a818466f7 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -61,6 +61,7 @@ class MDB2SchemaManager { $toSchema = $schemaReader->loadSchemaFromFile($file); // remove tables we don't know about + /** @var $table \Doctrine\DBAL\Schema\Table */ foreach($fromSchema->getTables() as $table) { if (!$toSchema->hasTable($table->getName())) { $fromSchema->dropTable($table->getName()); @@ -76,12 +77,6 @@ class MDB2SchemaManager { $comparator = new \Doctrine\DBAL\Schema\Comparator(); $schemaDiff = $comparator->compare($fromSchema, $toSchema); - $platform = $this->conn->getDatabasePlatform(); - $tables = $schemaDiff->newTables + $schemaDiff->changedTables + $schemaDiff->removedTables; - foreach($tables as $tableDiff) { - $tableDiff->name = $platform->quoteIdentifier($tableDiff->name); - } - if ($generateSql) { return $this->generateChangeScript($schemaDiff); } @@ -110,6 +105,7 @@ class MDB2SchemaManager { $schemaReader = new MDB2SchemaReader(\OC_Config::getObject(), $this->conn->getDatabasePlatform()); $fromSchema = $schemaReader->loadSchemaFromFile($file); $toSchema = clone $fromSchema; + /** @var $table \Doctrine\DBAL\Schema\Table */ foreach($toSchema->getTables() as $table) { $toSchema->dropTable($table->getName()); } From 97aff7c64ee8164a6ba468b6ccb2ee05fa689cf1 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 21 Oct 2013 22:31:57 +0300 Subject: [PATCH 2/2] Use quoteIdentifier with proper objects --- lib/private/db/mdb2schemamanager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index 8a818466f7..416e2f5542 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -77,6 +77,11 @@ class MDB2SchemaManager { $comparator = new \Doctrine\DBAL\Schema\Comparator(); $schemaDiff = $comparator->compare($fromSchema, $toSchema); + $platform = $this->conn->getDatabasePlatform(); + foreach($schemaDiff->changedTables as $tableDiff) { + $tableDiff->name = $platform->quoteIdentifier($tableDiff->name); + } + if ($generateSql) { return $this->generateChangeScript($schemaDiff); }