summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-07-12 16:52:08 +0200
committerJoas Schilling <coding@schilljs.com>2018-07-27 14:45:21 +0200
commit8a45cb1d2030b4dfd6ff918fc251e12eb0f10445 (patch)
treec30b8745a8455730c9a45066327a7cc4236485ee /lib/private
parent5edab3b31153d5d328c746f57c90ffbcc8dd6170 (diff)
downloadnextcloud-server-8a45cb1d2030b4dfd6ff918fc251e12eb0f10445.tar.gz
nextcloud-server-8a45cb1d2030b4dfd6ff918fc251e12eb0f10445.zip
Prevent too long identifier names
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DB/MigrationService.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index 6f5a74103a5..b2ec3c13ba1 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -23,6 +23,7 @@
namespace OC\DB;
+use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use OC\IntegrityCheck\Helpers\AppLocator;
use OC\Migration\SimpleOutput;
@@ -450,7 +451,9 @@ class MigrationService {
}, ['tablePrefix' => $this->connection->getPrefix()]);
if ($toSchema instanceof SchemaWrapper) {
- $this->connection->migrateToSchema($toSchema->getWrappedSchema());
+ $targetSchema = $toSchema->getWrappedSchema();
+ $this->ensureOracleIdentifierLengthLimit($targetSchema);
+ $this->connection->migrateToSchema($targetSchema);
$toSchema->performDropTableCalls();
}
@@ -463,6 +466,43 @@ class MigrationService {
$this->markAsExecuted($version);
}
+ public function ensureOracleIdentifierLengthLimit(Schema $schema) {
+ foreach ($schema->getTables() as $table) {
+ if (\strlen($table->getName()) > 30) {
+ throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.');
+ }
+
+ foreach ($table->getColumns() as $thing) {
+ if (\strlen($thing->getName()) > 30) {
+ throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
+ }
+ }
+
+ foreach ($table->getIndexes() as $thing) {
+ if (\strlen($thing->getName()) > 30) {
+ throw new \InvalidArgumentException('Index name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
+ }
+ }
+
+ foreach ($table->getForeignKeys() as $thing) {
+ if (\strlen($thing->getName()) > 30) {
+ throw new \InvalidArgumentException('Foreign key name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.');
+ }
+ }
+
+ $thing = $table->getPrimaryKey();
+ if ($thing && (\strlen($table->getName()) > 26 || \strlen($thing->getName()) > 30)) {
+ throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.');
+ }
+ }
+
+ foreach ($schema->getSequences() as $sequence) {
+ if (\strlen($sequence->getName()) > 30) {
+ throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.');
+ }
+ }
+ }
+
private function ensureMigrationsAreLoaded() {
if (empty($this->migrations)) {
$this->migrations = $this->findMigrations();