From c09fa1ee65dc944a8e9c689a441da9c7a440dd02 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2018 18:36:38 +0200 Subject: [PATCH] Only check the Oracle schema conditions if the app supports it Signed-off-by: Joas Schilling --- lib/private/DB/MigrationService.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 62072accbc1aa..97f1dd269d130 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -30,6 +30,7 @@ use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; +use OC\App\InfoParser; use OC\IntegrityCheck\Helpers\AppLocator; use OC\Migration\SimpleOutput; use OCP\AppFramework\App; @@ -51,6 +52,8 @@ class MigrationService { private $connection; /** @var string */ private $appName; + /** @var bool */ + private $checkOracle; /** * MigrationService constructor. @@ -72,6 +75,7 @@ public function __construct($appName, IDBConnection $connection, IOutput $output if ($appName === 'core') { $this->migrationsPath = \OC::$SERVERROOT . '/core/Migrations'; $this->migrationsNamespace = 'OC\\Core\\Migrations'; + $this->checkOracle = true; } else { if (null === $appLocator) { $appLocator = new AppLocator(); @@ -80,6 +84,21 @@ public function __construct($appName, IDBConnection $connection, IOutput $output $namespace = App::buildAppNamespace($appName); $this->migrationsPath = "$appPath/lib/Migration"; $this->migrationsNamespace = $namespace . '\\Migration'; + + $infoParser = new InfoParser(); + $info = $infoParser->parse($appPath . '/appinfo/info.xml'); + if (!isset($info['dependencies']['database'])) { + $this->checkOracle = true; + } else { + $this->checkOracle = false; + foreach ($info['dependencies']['database'] as $database) { + if (\is_string($database) && $database === 'oci') { + $this->checkOracle = true; + } else if (\is_array($database) && isset($database['@value']) && $database['@value'] === 'oci') { + $this->checkOracle = true; + } + } + } } } @@ -456,9 +475,11 @@ public function executeStep($version, $schemaOnly = false) { }, ['tablePrefix' => $this->connection->getPrefix()]); if ($toSchema instanceof SchemaWrapper) { - $sourceSchema = $this->connection->createSchema(); $targetSchema = $toSchema->getWrappedSchema(); - $this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix())); + if ($this->checkOracle) { + $sourceSchema = $this->connection->createSchema(); + $this->ensureOracleIdentifierLengthLimit($sourceSchema, $targetSchema, strlen($this->connection->getPrefix())); + } $this->connection->migrateToSchema($targetSchema); $toSchema->performDropTableCalls(); }