Passed
Push — master ( ebedbf...47a21f )
by Joas
12:46 queued 18s
created
core/Command/Db/Migrations/GenerateCommand.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 use Symfony\Component\Console\Output\OutputInterface;
39 39
 
40 40
 class GenerateCommand extends Command implements CompletionAwareInterface {
41
-	protected static $_templateSimple =
42
-		'<?php
41
+    protected static $_templateSimple =
42
+        '<?php
43 43
 
44 44
 declare(strict_types=1);
45 45
 
@@ -83,129 +83,129 @@  discard block
 block discarded – undo
83 83
 }
84 84
 ';
85 85
 
86
-	/** @var IDBConnection */
87
-	protected $connection;
88
-
89
-	/** @var IAppManager */
90
-	protected $appManager;
91
-
92
-	/**
93
-	 * @param IDBConnection $connection
94
-	 * @param IAppManager $appManager
95
-	 */
96
-	public function __construct(IDBConnection $connection, IAppManager $appManager) {
97
-		$this->connection = $connection;
98
-		$this->appManager = $appManager;
99
-
100
-		parent::__construct();
101
-	}
102
-
103
-	protected function configure() {
104
-		$this
105
-			->setName('migrations:generate')
106
-			->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on')
107
-			->addArgument('version', InputArgument::REQUIRED, 'Major version of this app, to allow versions on parallel development branches')
108
-		;
109
-
110
-		parent::configure();
111
-	}
112
-
113
-	public function execute(InputInterface $input, OutputInterface $output): int {
114
-		$appName = $input->getArgument('app');
115
-		$version = $input->getArgument('version');
116
-
117
-		if (!preg_match('/^\d{1,16}$/',$version)) {
118
-			$output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
119
-			return 1;
120
-		}
121
-
122
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
123
-
124
-		$date = date('YmdHis');
125
-		$path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date);
126
-
127
-		$output->writeln("New migration class has been generated to <info>$path</info>");
128
-		return 0;
129
-	}
130
-
131
-	/**
132
-	 * @param string $optionName
133
-	 * @param CompletionContext $context
134
-	 * @return string[]
135
-	 */
136
-	public function completeOptionValues($optionName, CompletionContext $context) {
137
-		return [];
138
-	}
139
-
140
-	/**
141
-	 * @param string $argumentName
142
-	 * @param CompletionContext $context
143
-	 * @return string[]
144
-	 */
145
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
146
-		if ($argumentName === 'app') {
147
-			$allApps = \OC_App::getAllApps();
148
-			return array_diff($allApps, \OC_App::getEnabledApps(true, true));
149
-		}
150
-
151
-		if ($argumentName === 'version') {
152
-			$appName = $context->getWordAtIndex($context->getWordIndex() - 1);
153
-
154
-			$version = explode('.', $this->appManager->getAppVersion($appName));
155
-			return [$version[0] . sprintf('%1$03d', $version[1])];
156
-		}
157
-
158
-		return [];
159
-	}
160
-
161
-	/**
162
-	 * @param MigrationService $ms
163
-	 * @param string $className
164
-	 * @param string $schemaBody
165
-	 * @return string
166
-	 */
167
-	protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') {
168
-		if ($schemaBody === '') {
169
-			$schemaBody = "\t\t" . 'return null;';
170
-		}
171
-
172
-
173
-		$placeHolders = [
174
-			'{{namespace}}',
175
-			'{{classname}}',
176
-			'{{schemabody}}',
177
-		];
178
-		$replacements = [
179
-			$ms->getMigrationsNamespace(),
180
-			$className,
181
-			$schemaBody,
182
-		];
183
-		$code = str_replace($placeHolders, $replacements, self::$_templateSimple);
184
-		$dir = $ms->getMigrationsDirectory();
185
-
186
-		$this->ensureMigrationDirExists($dir);
187
-		$path = $dir . '/' . $className . '.php';
188
-
189
-		if (file_put_contents($path, $code) === false) {
190
-			throw new RuntimeException('Failed to generate new migration step.');
191
-		}
192
-
193
-		return $path;
194
-	}
195
-
196
-	protected function ensureMigrationDirExists($directory) {
197
-		if (file_exists($directory) && is_dir($directory)) {
198
-			return;
199
-		}
200
-
201
-		if (file_exists($directory)) {
202
-			throw new \RuntimeException("Could not create folder \"$directory\"");
203
-		}
204
-
205
-		$this->ensureMigrationDirExists(dirname($directory));
206
-
207
-		if (!@mkdir($directory) && !is_dir($directory)) {
208
-			throw new \RuntimeException("Could not create folder \"$directory\"");
209
-		}
210
-	}
86
+    /** @var IDBConnection */
87
+    protected $connection;
88
+
89
+    /** @var IAppManager */
90
+    protected $appManager;
91
+
92
+    /**
93
+     * @param IDBConnection $connection
94
+     * @param IAppManager $appManager
95
+     */
96
+    public function __construct(IDBConnection $connection, IAppManager $appManager) {
97
+        $this->connection = $connection;
98
+        $this->appManager = $appManager;
99
+
100
+        parent::__construct();
101
+    }
102
+
103
+    protected function configure() {
104
+        $this
105
+            ->setName('migrations:generate')
106
+            ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on')
107
+            ->addArgument('version', InputArgument::REQUIRED, 'Major version of this app, to allow versions on parallel development branches')
108
+        ;
109
+
110
+        parent::configure();
111
+    }
112
+
113
+    public function execute(InputInterface $input, OutputInterface $output): int {
114
+        $appName = $input->getArgument('app');
115
+        $version = $input->getArgument('version');
116
+
117
+        if (!preg_match('/^\d{1,16}$/',$version)) {
118
+            $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
119
+            return 1;
120
+        }
121
+
122
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
123
+
124
+        $date = date('YmdHis');
125
+        $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date);
126
+
127
+        $output->writeln("New migration class has been generated to <info>$path</info>");
128
+        return 0;
129
+    }
130
+
131
+    /**
132
+     * @param string $optionName
133
+     * @param CompletionContext $context
134
+     * @return string[]
135
+     */
136
+    public function completeOptionValues($optionName, CompletionContext $context) {
137
+        return [];
138
+    }
139
+
140
+    /**
141
+     * @param string $argumentName
142
+     * @param CompletionContext $context
143
+     * @return string[]
144
+     */
145
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
146
+        if ($argumentName === 'app') {
147
+            $allApps = \OC_App::getAllApps();
148
+            return array_diff($allApps, \OC_App::getEnabledApps(true, true));
149
+        }
150
+
151
+        if ($argumentName === 'version') {
152
+            $appName = $context->getWordAtIndex($context->getWordIndex() - 1);
153
+
154
+            $version = explode('.', $this->appManager->getAppVersion($appName));
155
+            return [$version[0] . sprintf('%1$03d', $version[1])];
156
+        }
157
+
158
+        return [];
159
+    }
160
+
161
+    /**
162
+     * @param MigrationService $ms
163
+     * @param string $className
164
+     * @param string $schemaBody
165
+     * @return string
166
+     */
167
+    protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') {
168
+        if ($schemaBody === '') {
169
+            $schemaBody = "\t\t" . 'return null;';
170
+        }
171
+
172
+
173
+        $placeHolders = [
174
+            '{{namespace}}',
175
+            '{{classname}}',
176
+            '{{schemabody}}',
177
+        ];
178
+        $replacements = [
179
+            $ms->getMigrationsNamespace(),
180
+            $className,
181
+            $schemaBody,
182
+        ];
183
+        $code = str_replace($placeHolders, $replacements, self::$_templateSimple);
184
+        $dir = $ms->getMigrationsDirectory();
185
+
186
+        $this->ensureMigrationDirExists($dir);
187
+        $path = $dir . '/' . $className . '.php';
188
+
189
+        if (file_put_contents($path, $code) === false) {
190
+            throw new RuntimeException('Failed to generate new migration step.');
191
+        }
192
+
193
+        return $path;
194
+    }
195
+
196
+    protected function ensureMigrationDirExists($directory) {
197
+        if (file_exists($directory) && is_dir($directory)) {
198
+            return;
199
+        }
200
+
201
+        if (file_exists($directory)) {
202
+            throw new \RuntimeException("Could not create folder \"$directory\"");
203
+        }
204
+
205
+        $this->ensureMigrationDirExists(dirname($directory));
206
+
207
+        if (!@mkdir($directory) && !is_dir($directory)) {
208
+            throw new \RuntimeException("Could not create folder \"$directory\"");
209
+        }
210
+    }
211 211
 }
Please login to merge, or discard this patch.
core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -37,170 +37,170 @@
 block discarded – undo
37 37
 
38 38
 class GenerateFromSchemaFileCommand extends GenerateCommand {
39 39
 
40
-	/** @var IConfig */
41
-	protected $config;
40
+    /** @var IConfig */
41
+    protected $config;
42 42
 
43
-	public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) {
44
-		parent::__construct($connection, $appManager);
45
-		$this->config = $config;
46
-	}
43
+    public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) {
44
+        parent::__construct($connection, $appManager);
45
+        $this->config = $config;
46
+    }
47 47
 
48 48
 
49
-	protected function configure() {
50
-		parent::configure();
49
+    protected function configure() {
50
+        parent::configure();
51 51
 
52
-		$this->setName('migrations:generate-from-schema');
53
-	}
52
+        $this->setName('migrations:generate-from-schema');
53
+    }
54 54
 
55
-	public function execute(InputInterface $input, OutputInterface $output): int {
56
-		$appName = $input->getArgument('app');
57
-		$version = $input->getArgument('version');
55
+    public function execute(InputInterface $input, OutputInterface $output): int {
56
+        $appName = $input->getArgument('app');
57
+        $version = $input->getArgument('version');
58 58
 
59
-		if (!preg_match('/^\d{1,16}$/',$version)) {
60
-			$output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
61
-			return 1;
62
-		}
59
+        if (!preg_match('/^\d{1,16}$/',$version)) {
60
+            $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
61
+            return 1;
62
+        }
63 63
 
64
-		$schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml';
65
-		if (!file_exists($schemaFile)) {
66
-			$output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>');
67
-			return 2;
68
-		}
64
+        $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml';
65
+        if (!file_exists($schemaFile)) {
66
+            $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>');
67
+            return 2;
68
+        }
69 69
 
70
-		$reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform());
71
-		$schema = new Schema();
72
-		$reader->loadSchemaFromFile($schemaFile, $schema);
70
+        $reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform());
71
+        $schema = new Schema();
72
+        $reader->loadSchemaFromFile($schemaFile, $schema);
73 73
 
74
-		$schemaBody = $this->schemaToMigration($schema);
74
+        $schemaBody = $this->schemaToMigration($schema);
75 75
 
76
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
76
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
77 77
 
78
-		$date = date('YmdHis');
79
-		$path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody);
78
+        $date = date('YmdHis');
79
+        $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody);
80 80
 
81
-		$output->writeln("New migration class has been generated to <info>$path</info>");
82
-		return 0;
83
-	}
81
+        $output->writeln("New migration class has been generated to <info>$path</info>");
82
+        return 0;
83
+    }
84 84
 
85
-	/**
86
-	 * @param Schema $schema
87
-	 * @return string
88
-	 */
89
-	protected function schemaToMigration(Schema $schema) {
90
-		$content = <<<'EOT'
85
+    /**
86
+     * @param Schema $schema
87
+     * @return string
88
+     */
89
+    protected function schemaToMigration(Schema $schema) {
90
+        $content = <<<'EOT'
91 91
 		/** @var ISchemaWrapper $schema */
92 92
 		$schema = $schemaClosure();
93 93
 
94 94
 EOT;
95 95
 
96
-		foreach ($schema->getTables() as $table) {
97
-			$content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT'
96
+        foreach ($schema->getTables() as $table) {
97
+            $content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT'
98 98
 
99 99
 		if (!$schema->hasTable('{{table-name}}')) {
100 100
 			$table = $schema->createTable('{{table-name}}');
101 101
 
102 102
 EOT
103
-			);
103
+            );
104 104
 
105
-			foreach ($table->getColumns() as $column) {
106
-				$content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT'
105
+            foreach ($table->getColumns() as $column) {
106
+                $content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT'
107 107
 			$table->addColumn('{{name}}', '{{type}}', [
108 108
 
109 109
 EOT
110
-				);
111
-				if ($column->getAutoincrement()) {
112
-					$content .= <<<'EOT'
110
+                );
111
+                if ($column->getAutoincrement()) {
112
+                    $content .= <<<'EOT'
113 113
 				'autoincrement' => true,
114 114
 
115 115
 EOT;
116
-				}
117
-				$content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT'
116
+                }
117
+                $content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT'
118 118
 				'notnull' => {{notnull}},
119 119
 
120 120
 EOT
121
-				);
122
-				if ($column->getLength() !== null) {
123
-					$content .= str_replace('{{length}}', $column->getLength(), <<<'EOT'
121
+                );
122
+                if ($column->getLength() !== null) {
123
+                    $content .= str_replace('{{length}}', $column->getLength(), <<<'EOT'
124 124
 				'length' => {{length}},
125 125
 
126 126
 EOT
127
-					);
128
-				}
129
-				$default = $column->getDefault();
130
-				if ($default !== null) {
131
-					if (is_string($default)) {
132
-						$default = "'$default'";
133
-					} elseif (is_bool($default)) {
134
-						$default = ($default === true) ? 'true' : 'false';
135
-					}
136
-					$content .= str_replace('{{default}}', $default, <<<'EOT'
127
+                    );
128
+                }
129
+                $default = $column->getDefault();
130
+                if ($default !== null) {
131
+                    if (is_string($default)) {
132
+                        $default = "'$default'";
133
+                    } elseif (is_bool($default)) {
134
+                        $default = ($default === true) ? 'true' : 'false';
135
+                    }
136
+                    $content .= str_replace('{{default}}', $default, <<<'EOT'
137 137
 				'default' => {{default}},
138 138
 
139 139
 EOT
140
-					);
141
-				}
142
-				if ($column->getUnsigned()) {
143
-					$content .= <<<'EOT'
140
+                    );
141
+                }
142
+                if ($column->getUnsigned()) {
143
+                    $content .= <<<'EOT'
144 144
 				'unsigned' => true,
145 145
 
146 146
 EOT;
147
-				}
147
+                }
148 148
 
149
-				$content .= <<<'EOT'
149
+                $content .= <<<'EOT'
150 150
 			]);
151 151
 
152 152
 EOT;
153
-			}
153
+            }
154 154
 
155
-			$content .= <<<'EOT'
155
+            $content .= <<<'EOT'
156 156
 
157 157
 EOT;
158 158
 
159
-			$primaryKey = $table->getPrimaryKey();
160
-			if ($primaryKey !== null) {
161
-				$content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT'
159
+            $primaryKey = $table->getPrimaryKey();
160
+            if ($primaryKey !== null) {
161
+                $content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT'
162 162
 			$table->setPrimaryKey(['{{columns}}']);
163 163
 
164 164
 EOT
165
-				);
166
-			}
167
-
168
-			foreach ($table->getIndexes() as $index) {
169
-				if ($index->isPrimary()) {
170
-					continue;
171
-				}
172
-
173
-				if ($index->isUnique()) {
174
-					$content .= str_replace(
175
-						['{{columns}}', '{{name}}'],
176
-						[implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
177
-						<<<'EOT'
165
+                );
166
+            }
167
+
168
+            foreach ($table->getIndexes() as $index) {
169
+                if ($index->isPrimary()) {
170
+                    continue;
171
+                }
172
+
173
+                if ($index->isUnique()) {
174
+                    $content .= str_replace(
175
+                        ['{{columns}}', '{{name}}'],
176
+                        [implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
177
+                        <<<'EOT'
178 178
 			$table->addUniqueIndex(['{{columns}}'], '{{name}}');
179 179
 
180 180
 EOT
181
-					);
182
-				} else {
183
-					$content .= str_replace(
184
-						['{{columns}}', '{{name}}'],
185
-						[implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
186
-						<<<'EOT'
181
+                    );
182
+                } else {
183
+                    $content .= str_replace(
184
+                        ['{{columns}}', '{{name}}'],
185
+                        [implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
186
+                        <<<'EOT'
187 187
 			$table->addIndex(['{{columns}}'], '{{name}}');
188 188
 
189 189
 EOT
190
-					);
191
-				}
192
-			}
190
+                    );
191
+                }
192
+            }
193 193
 
194
-			$content .= <<<'EOT'
194
+            $content .= <<<'EOT'
195 195
 		}
196 196
 
197 197
 EOT;
198
-		}
198
+        }
199 199
 
200
-		$content .= <<<'EOT'
200
+        $content .= <<<'EOT'
201 201
 		return $schema;
202 202
 EOT;
203 203
 
204
-		return $content;
205
-	}
204
+        return $content;
205
+    }
206 206
 }
Please login to merge, or discard this patch.
core/Command/Db/Migrations/StatusCommand.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -35,114 +35,114 @@
 block discarded – undo
35 35
 
36 36
 class StatusCommand extends Command implements CompletionAwareInterface {
37 37
 
38
-	/** @var IDBConnection */
39
-	private $connection;
40
-
41
-	/**
42
-	 * @param IDBConnection $connection
43
-	 */
44
-	public function __construct(IDBConnection $connection) {
45
-		$this->connection = $connection;
46
-		parent::__construct();
47
-	}
48
-
49
-	protected function configure() {
50
-		$this
51
-			->setName('migrations:status')
52
-			->setDescription('View the status of a set of migrations.')
53
-			->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on');
54
-	}
55
-
56
-	public function execute(InputInterface $input, OutputInterface $output): int {
57
-		$appName = $input->getArgument('app');
58
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
59
-
60
-		$infos = $this->getMigrationsInfos($ms);
61
-		foreach ($infos as $key => $value) {
62
-			if (is_array($value)) {
63
-				$output->writeln("    <comment>>></comment> $key:");
64
-				foreach ($value as $subKey => $subValue) {
65
-					$output->writeln("        <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue);
66
-				}
67
-			} else {
68
-				$output->writeln("    <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value);
69
-			}
70
-		}
71
-		return 0;
72
-	}
73
-
74
-	/**
75
-	 * @param string $optionName
76
-	 * @param CompletionContext $context
77
-	 * @return string[]
78
-	 */
79
-	public function completeOptionValues($optionName, CompletionContext $context) {
80
-		return [];
81
-	}
82
-
83
-	/**
84
-	 * @param string $argumentName
85
-	 * @param CompletionContext $context
86
-	 * @return string[]
87
-	 */
88
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
89
-		if ($argumentName === 'app') {
90
-			$allApps = \OC_App::getAllApps();
91
-			return array_diff($allApps, \OC_App::getEnabledApps(true, true));
92
-		}
93
-		return [];
94
-	}
95
-
96
-	/**
97
-	 * @param MigrationService $ms
98
-	 * @return array associative array of human readable info name as key and the actual information as value
99
-	 */
100
-	public function getMigrationsInfos(MigrationService $ms) {
101
-		$executedMigrations = $ms->getMigratedVersions();
102
-		$availableMigrations = $ms->getAvailableVersions();
103
-		$executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations));
104
-
105
-		$numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
106
-		$numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations));
107
-		$pending = $ms->describeMigrationStep('lastest');
108
-
109
-		$infos = [
110
-			'App'								=> $ms->getApp(),
111
-			'Version Table Name'				=> $ms->getMigrationsTableName(),
112
-			'Migrations Namespace'				=> $ms->getMigrationsNamespace(),
113
-			'Migrations Directory'				=> $ms->getMigrationsDirectory(),
114
-			'Previous Version'					=> $this->getFormattedVersionAlias($ms, 'prev'),
115
-			'Current Version'					=> $this->getFormattedVersionAlias($ms, 'current'),
116
-			'Next Version'						=> $this->getFormattedVersionAlias($ms, 'next'),
117
-			'Latest Version'					=> $this->getFormattedVersionAlias($ms, 'latest'),
118
-			'Executed Migrations'				=> count($executedMigrations),
119
-			'Executed Unavailable Migrations'	=> $numExecutedUnavailableMigrations,
120
-			'Available Migrations'				=> count($availableMigrations),
121
-			'New Migrations'					=> $numNewMigrations,
122
-			'Pending Migrations'				=> count($pending) ? $pending : 'None'
123
-		];
124
-
125
-		return $infos;
126
-	}
127
-
128
-	/**
129
-	 * @param MigrationService $migrationService
130
-	 * @param string $alias
131
-	 * @return mixed|null|string
132
-	 */
133
-	private function getFormattedVersionAlias(MigrationService $migrationService, $alias) {
134
-		$migration = $migrationService->getMigration($alias);
135
-		//No version found
136
-		if ($migration === null) {
137
-			if ($alias === 'next') {
138
-				return 'Already at latest migration step';
139
-			}
140
-
141
-			if ($alias === 'prev') {
142
-				return 'Already at first migration step';
143
-			}
144
-		}
145
-
146
-		return $migration;
147
-	}
38
+    /** @var IDBConnection */
39
+    private $connection;
40
+
41
+    /**
42
+     * @param IDBConnection $connection
43
+     */
44
+    public function __construct(IDBConnection $connection) {
45
+        $this->connection = $connection;
46
+        parent::__construct();
47
+    }
48
+
49
+    protected function configure() {
50
+        $this
51
+            ->setName('migrations:status')
52
+            ->setDescription('View the status of a set of migrations.')
53
+            ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on');
54
+    }
55
+
56
+    public function execute(InputInterface $input, OutputInterface $output): int {
57
+        $appName = $input->getArgument('app');
58
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
59
+
60
+        $infos = $this->getMigrationsInfos($ms);
61
+        foreach ($infos as $key => $value) {
62
+            if (is_array($value)) {
63
+                $output->writeln("    <comment>>></comment> $key:");
64
+                foreach ($value as $subKey => $subValue) {
65
+                    $output->writeln("        <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue);
66
+                }
67
+            } else {
68
+                $output->writeln("    <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value);
69
+            }
70
+        }
71
+        return 0;
72
+    }
73
+
74
+    /**
75
+     * @param string $optionName
76
+     * @param CompletionContext $context
77
+     * @return string[]
78
+     */
79
+    public function completeOptionValues($optionName, CompletionContext $context) {
80
+        return [];
81
+    }
82
+
83
+    /**
84
+     * @param string $argumentName
85
+     * @param CompletionContext $context
86
+     * @return string[]
87
+     */
88
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
89
+        if ($argumentName === 'app') {
90
+            $allApps = \OC_App::getAllApps();
91
+            return array_diff($allApps, \OC_App::getEnabledApps(true, true));
92
+        }
93
+        return [];
94
+    }
95
+
96
+    /**
97
+     * @param MigrationService $ms
98
+     * @return array associative array of human readable info name as key and the actual information as value
99
+     */
100
+    public function getMigrationsInfos(MigrationService $ms) {
101
+        $executedMigrations = $ms->getMigratedVersions();
102
+        $availableMigrations = $ms->getAvailableVersions();
103
+        $executedUnavailableMigrations = array_diff($executedMigrations, array_keys($availableMigrations));
104
+
105
+        $numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
106
+        $numNewMigrations = count(array_diff(array_keys($availableMigrations), $executedMigrations));
107
+        $pending = $ms->describeMigrationStep('lastest');
108
+
109
+        $infos = [
110
+            'App'								=> $ms->getApp(),
111
+            'Version Table Name'				=> $ms->getMigrationsTableName(),
112
+            'Migrations Namespace'				=> $ms->getMigrationsNamespace(),
113
+            'Migrations Directory'				=> $ms->getMigrationsDirectory(),
114
+            'Previous Version'					=> $this->getFormattedVersionAlias($ms, 'prev'),
115
+            'Current Version'					=> $this->getFormattedVersionAlias($ms, 'current'),
116
+            'Next Version'						=> $this->getFormattedVersionAlias($ms, 'next'),
117
+            'Latest Version'					=> $this->getFormattedVersionAlias($ms, 'latest'),
118
+            'Executed Migrations'				=> count($executedMigrations),
119
+            'Executed Unavailable Migrations'	=> $numExecutedUnavailableMigrations,
120
+            'Available Migrations'				=> count($availableMigrations),
121
+            'New Migrations'					=> $numNewMigrations,
122
+            'Pending Migrations'				=> count($pending) ? $pending : 'None'
123
+        ];
124
+
125
+        return $infos;
126
+    }
127
+
128
+    /**
129
+     * @param MigrationService $migrationService
130
+     * @param string $alias
131
+     * @return mixed|null|string
132
+     */
133
+    private function getFormattedVersionAlias(MigrationService $migrationService, $alias) {
134
+        $migration = $migrationService->getMigration($alias);
135
+        //No version found
136
+        if ($migration === null) {
137
+            if ($alias === 'next') {
138
+                return 'Already at latest migration step';
139
+            }
140
+
141
+            if ($alias === 'prev') {
142
+                return 'Already at first migration step';
143
+            }
144
+        }
145
+
146
+        return $migration;
147
+    }
148 148
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@
 block discarded – undo
62 62
 			if (is_array($value)) {
63 63
 				$output->writeln("    <comment>>></comment> $key:");
64 64
 				foreach ($value as $subKey => $subValue) {
65
-					$output->writeln("        <comment>>></comment> $subKey: " . str_repeat(' ', 46 - strlen($subKey)) . $subValue);
65
+					$output->writeln("        <comment>>></comment> $subKey: ".str_repeat(' ', 46 - strlen($subKey)).$subValue);
66 66
 				}
67 67
 			} else {
68
-				$output->writeln("    <comment>>></comment> $key: " . str_repeat(' ', 50 - strlen($key)) . $value);
68
+				$output->writeln("    <comment>>></comment> $key: ".str_repeat(' ', 50 - strlen($key)).$value);
69 69
 			}
70 70
 		}
71 71
 		return 0;
Please login to merge, or discard this patch.
core/Command/Db/Migrations/ExecuteCommand.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -37,94 +37,94 @@
 block discarded – undo
37 37
 
38 38
 class ExecuteCommand extends Command implements CompletionAwareInterface {
39 39
 
40
-	/** @var IDBConnection */
41
-	private $connection;
42
-
43
-	/** @var IConfig */
44
-	private $config;
45
-
46
-	/** @var IAppManager */
47
-	protected $appManager;
48
-
49
-	/**
50
-	 * ExecuteCommand constructor.
51
-	 *
52
-	 * @param IDBConnection $connection
53
-	 * @param IConfig $config
54
-	 * @param IAppManager $appManager
55
-	 */
56
-	public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) {
57
-		$this->connection = $connection;
58
-		$this->config = $config;
59
-
60
-		parent::__construct();
61
-	}
62
-
63
-	protected function configure() {
64
-		$this
65
-			->setName('migrations:execute')
66
-			->setDescription('Execute a single migration version manually.')
67
-			->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on')
68
-			->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null);
69
-
70
-		parent::configure();
71
-	}
72
-
73
-	/**
74
-	 * @param InputInterface $input
75
-	 * @param OutputInterface $output
76
-	 * @return int
77
-	 */
78
-	public function execute(InputInterface $input, OutputInterface $output): int {
79
-		$appName = $input->getArgument('app');
80
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
81
-		$version = $input->getArgument('version');
82
-
83
-		if ($this->config->getSystemValue('debug', false) === false) {
84
-			$olderVersions = $ms->getMigratedVersions();
85
-			$olderVersions[] = '0';
86
-			$olderVersions[] = 'prev';
87
-			if (in_array($version,  $olderVersions, true)) {
88
-				$output->writeln('<error>Can not go back to previous migration without debug enabled</error>');
89
-				return 1;
90
-			}
91
-		}
92
-
93
-
94
-		$ms->executeStep($version);
95
-		return 0;
96
-	}
97
-
98
-	/**
99
-	 * @param string $optionName
100
-	 * @param CompletionContext $context
101
-	 * @return string[]
102
-	 */
103
-	public function completeOptionValues($optionName, CompletionContext $context) {
104
-		return [];
105
-	}
106
-
107
-	/**
108
-	 * @param string $argumentName
109
-	 * @param CompletionContext $context
110
-	 * @return string[]
111
-	 */
112
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
113
-		if ($argumentName === 'app') {
114
-			$allApps = \OC_App::getAllApps();
115
-			return array_diff($allApps, \OC_App::getEnabledApps(true, true));
116
-		}
117
-
118
-		if ($argumentName === 'version') {
119
-			$appName = $context->getWordAtIndex($context->getWordIndex() - 1);
120
-
121
-			$ms = new MigrationService($appName, $this->connection);
122
-			$migrations = $ms->getAvailableVersions();
123
-
124
-			array_unshift($migrations, 'next', 'latest');
125
-			return $migrations;
126
-		}
127
-
128
-		return [];
129
-	}
40
+    /** @var IDBConnection */
41
+    private $connection;
42
+
43
+    /** @var IConfig */
44
+    private $config;
45
+
46
+    /** @var IAppManager */
47
+    protected $appManager;
48
+
49
+    /**
50
+     * ExecuteCommand constructor.
51
+     *
52
+     * @param IDBConnection $connection
53
+     * @param IConfig $config
54
+     * @param IAppManager $appManager
55
+     */
56
+    public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) {
57
+        $this->connection = $connection;
58
+        $this->config = $config;
59
+
60
+        parent::__construct();
61
+    }
62
+
63
+    protected function configure() {
64
+        $this
65
+            ->setName('migrations:execute')
66
+            ->setDescription('Execute a single migration version manually.')
67
+            ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on')
68
+            ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null);
69
+
70
+        parent::configure();
71
+    }
72
+
73
+    /**
74
+     * @param InputInterface $input
75
+     * @param OutputInterface $output
76
+     * @return int
77
+     */
78
+    public function execute(InputInterface $input, OutputInterface $output): int {
79
+        $appName = $input->getArgument('app');
80
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
81
+        $version = $input->getArgument('version');
82
+
83
+        if ($this->config->getSystemValue('debug', false) === false) {
84
+            $olderVersions = $ms->getMigratedVersions();
85
+            $olderVersions[] = '0';
86
+            $olderVersions[] = 'prev';
87
+            if (in_array($version,  $olderVersions, true)) {
88
+                $output->writeln('<error>Can not go back to previous migration without debug enabled</error>');
89
+                return 1;
90
+            }
91
+        }
92
+
93
+
94
+        $ms->executeStep($version);
95
+        return 0;
96
+    }
97
+
98
+    /**
99
+     * @param string $optionName
100
+     * @param CompletionContext $context
101
+     * @return string[]
102
+     */
103
+    public function completeOptionValues($optionName, CompletionContext $context) {
104
+        return [];
105
+    }
106
+
107
+    /**
108
+     * @param string $argumentName
109
+     * @param CompletionContext $context
110
+     * @return string[]
111
+     */
112
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
113
+        if ($argumentName === 'app') {
114
+            $allApps = \OC_App::getAllApps();
115
+            return array_diff($allApps, \OC_App::getEnabledApps(true, true));
116
+        }
117
+
118
+        if ($argumentName === 'version') {
119
+            $appName = $context->getWordAtIndex($context->getWordIndex() - 1);
120
+
121
+            $ms = new MigrationService($appName, $this->connection);
122
+            $migrations = $ms->getAvailableVersions();
123
+
124
+            array_unshift($migrations, 'next', 'latest');
125
+            return $migrations;
126
+        }
127
+
128
+        return [];
129
+    }
130 130
 }
Please login to merge, or discard this patch.
core/Command/Db/AddMissingIndices.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -50,227 +50,227 @@
 block discarded – undo
50 50
  */
51 51
 class AddMissingIndices extends Command {
52 52
 
53
-	/** @var IDBConnection */
54
-	private $connection;
55
-
56
-	/** @var EventDispatcherInterface */
57
-	private $dispatcher;
58
-
59
-	public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
60
-		parent::__construct();
61
-
62
-		$this->connection = $connection;
63
-		$this->dispatcher = $dispatcher;
64
-	}
65
-
66
-	protected function configure() {
67
-		$this
68
-			->setName('db:add-missing-indices')
69
-			->setDescription('Add missing indices to the database tables');
70
-	}
71
-
72
-	protected function execute(InputInterface $input, OutputInterface $output): int {
73
-		$this->addCoreIndexes($output);
74
-
75
-		// Dispatch event so apps can also update indexes if needed
76
-		$event = new GenericEvent($output);
77
-		$this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
78
-		return 0;
79
-	}
80
-
81
-	/**
82
-	 * add missing indices to the share table
83
-	 *
84
-	 * @param OutputInterface $output
85
-	 * @throws \Doctrine\DBAL\Schema\SchemaException
86
-	 */
87
-	private function addCoreIndexes(OutputInterface $output) {
88
-		$output->writeln('<info>Check indices of the share table.</info>');
89
-
90
-		$schema = new SchemaWrapper($this->connection);
91
-		$updated = false;
92
-
93
-		if ($schema->hasTable('share')) {
94
-			$table = $schema->getTable('share');
95
-			if (!$table->hasIndex('share_with_index')) {
96
-				$output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>');
97
-				$table->addIndex(['share_with'], 'share_with_index');
98
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
99
-				$updated = true;
100
-				$output->writeln('<info>Share table updated successfully.</info>');
101
-			}
102
-
103
-			if (!$table->hasIndex('parent_index')) {
104
-				$output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>');
105
-				$table->addIndex(['parent'], 'parent_index');
106
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
107
-				$updated = true;
108
-				$output->writeln('<info>Share table updated successfully.</info>');
109
-			}
110
-
111
-			if (!$table->hasIndex('owner_index')) {
112
-				$output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>');
113
-				$table->addIndex(['uid_owner'], 'owner_index');
114
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
115
-				$updated = true;
116
-				$output->writeln('<info>Share table updated successfully.</info>');
117
-			}
118
-
119
-			if (!$table->hasIndex('initiator_index')) {
120
-				$output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>');
121
-				$table->addIndex(['uid_initiator'], 'initiator_index');
122
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
123
-				$updated = true;
124
-				$output->writeln('<info>Share table updated successfully.</info>');
125
-			}
126
-		}
127
-
128
-		$output->writeln('<info>Check indices of the filecache table.</info>');
129
-		if ($schema->hasTable('filecache')) {
130
-			$table = $schema->getTable('filecache');
131
-			if (!$table->hasIndex('fs_mtime')) {
132
-				$output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>');
133
-				$table->addIndex(['mtime'], 'fs_mtime');
134
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
135
-				$updated = true;
136
-				$output->writeln('<info>Filecache table updated successfully.</info>');
137
-			}
138
-		}
139
-
140
-		$output->writeln('<info>Check indices of the twofactor_providers table.</info>');
141
-		if ($schema->hasTable('twofactor_providers')) {
142
-			$table = $schema->getTable('twofactor_providers');
143
-			if (!$table->hasIndex('twofactor_providers_uid')) {
144
-				$output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>');
145
-				$table->addIndex(['uid'], 'twofactor_providers_uid');
146
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
147
-				$updated = true;
148
-				$output->writeln('<info>Twofactor_providers table updated successfully.</info>');
149
-			}
150
-		}
151
-
152
-		$output->writeln('<info>Check indices of the login_flow_v2 table.</info>');
153
-		if ($schema->hasTable('login_flow_v2')) {
154
-			$table = $schema->getTable('login_flow_v2');
155
-			if (!$table->hasIndex('poll_token')) {
156
-				$output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>');
157
-
158
-				foreach ($table->getIndexes() as $index) {
159
-					$columns = $index->getColumns();
160
-					if ($columns === ['poll_token'] ||
161
-						$columns === ['login_token'] ||
162
-						$columns === ['timestamp']) {
163
-						$table->dropIndex($index->getName());
164
-					}
165
-				}
166
-
167
-				$table->addUniqueIndex(['poll_token'], 'poll_token');
168
-				$table->addUniqueIndex(['login_token'], 'login_token');
169
-				$table->addIndex(['timestamp'], 'timestamp');
170
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
171
-				$updated = true;
172
-				$output->writeln('<info>login_flow_v2 table updated successfully.</info>');
173
-			}
174
-		}
175
-
176
-		$output->writeln('<info>Check indices of the whats_new table.</info>');
177
-		if ($schema->hasTable('whats_new')) {
178
-			$table = $schema->getTable('whats_new');
179
-			if (!$table->hasIndex('version')) {
180
-				$output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>');
181
-
182
-				foreach ($table->getIndexes() as $index) {
183
-					if ($index->getColumns() === ['version']) {
184
-						$table->dropIndex($index->getName());
185
-					}
186
-				}
187
-
188
-				$table->addUniqueIndex(['version'], 'version');
189
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
190
-				$updated = true;
191
-				$output->writeln('<info>whats_new table updated successfully.</info>');
192
-			}
193
-		}
194
-
195
-		$output->writeln('<info>Check indices of the cards table.</info>');
196
-		if ($schema->hasTable('cards')) {
197
-			$table = $schema->getTable('cards');
198
-			if (!$table->hasIndex('cards_abid')) {
199
-				$output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>');
200
-
201
-				foreach ($table->getIndexes() as $index) {
202
-					if ($index->getColumns() === ['addressbookid']) {
203
-						$table->dropIndex($index->getName());
204
-					}
205
-				}
206
-
207
-				$table->addIndex(['addressbookid'], 'cards_abid');
208
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
209
-				$updated = true;
210
-				$output->writeln('<info>cards table updated successfully.</info>');
211
-			}
212
-		}
213
-
214
-		$output->writeln('<info>Check indices of the cards_properties table.</info>');
215
-		if ($schema->hasTable('cards_properties')) {
216
-			$table = $schema->getTable('cards_properties');
217
-			if (!$table->hasIndex('cards_prop_abid')) {
218
-				$output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>');
219
-
220
-				foreach ($table->getIndexes() as $index) {
221
-					if ($index->getColumns() === ['addressbookid']) {
222
-						$table->dropIndex($index->getName());
223
-					}
224
-				}
225
-
226
-				$table->addIndex(['addressbookid'], 'cards_prop_abid');
227
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
228
-				$updated = true;
229
-				$output->writeln('<info>cards_properties table updated successfully.</info>');
230
-			}
231
-		}
232
-
233
-		$output->writeln('<info>Check indices of the calendarobjects_props table.</info>');
234
-		if ($schema->hasTable('calendarobjects_props')) {
235
-			$table = $schema->getTable('calendarobjects_props');
236
-			if (!$table->hasIndex('calendarobject_calid_index')) {
237
-				$output->writeln('<info>Adding calendarobject_calid_index index to the calendarobjects_props table, this can take some time...</info>');
238
-
239
-				$table->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
240
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
241
-				$updated = true;
242
-				$output->writeln('<info>calendarobjects_props table updated successfully.</info>');
243
-			}
244
-		}
245
-
246
-		$output->writeln('<info>Check indices of the schedulingobjects table.</info>');
247
-		if ($schema->hasTable('schedulingobjects')) {
248
-			$table = $schema->getTable('schedulingobjects');
249
-			if (!$table->hasIndex('schedulobj_principuri_index')) {
250
-				$output->writeln('<info>Adding schedulobj_principuri_index index to the schedulingobjects table, this can take some time...</info>');
251
-
252
-				$table->addIndex(['principaluri'], 'schedulobj_principuri_index');
253
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
254
-				$updated = true;
255
-				$output->writeln('<info>schedulingobjects table updated successfully.</info>');
256
-			}
257
-		}
258
-
259
-		$output->writeln('<info>Check indices of the oc_properties table.</info>');
260
-		if ($schema->hasTable('properties')) {
261
-			$table = $schema->getTable('properties');
262
-			if (!$table->hasIndex('properties_path_index')) {
263
-				$output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
264
-
265
-				$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
266
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
267
-				$updated = true;
268
-				$output->writeln('<info>oc_properties table updated successfully.</info>');
269
-			}
270
-		}
271
-
272
-		if (!$updated) {
273
-			$output->writeln('<info>Done.</info>');
274
-		}
275
-	}
53
+    /** @var IDBConnection */
54
+    private $connection;
55
+
56
+    /** @var EventDispatcherInterface */
57
+    private $dispatcher;
58
+
59
+    public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
60
+        parent::__construct();
61
+
62
+        $this->connection = $connection;
63
+        $this->dispatcher = $dispatcher;
64
+    }
65
+
66
+    protected function configure() {
67
+        $this
68
+            ->setName('db:add-missing-indices')
69
+            ->setDescription('Add missing indices to the database tables');
70
+    }
71
+
72
+    protected function execute(InputInterface $input, OutputInterface $output): int {
73
+        $this->addCoreIndexes($output);
74
+
75
+        // Dispatch event so apps can also update indexes if needed
76
+        $event = new GenericEvent($output);
77
+        $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event);
78
+        return 0;
79
+    }
80
+
81
+    /**
82
+     * add missing indices to the share table
83
+     *
84
+     * @param OutputInterface $output
85
+     * @throws \Doctrine\DBAL\Schema\SchemaException
86
+     */
87
+    private function addCoreIndexes(OutputInterface $output) {
88
+        $output->writeln('<info>Check indices of the share table.</info>');
89
+
90
+        $schema = new SchemaWrapper($this->connection);
91
+        $updated = false;
92
+
93
+        if ($schema->hasTable('share')) {
94
+            $table = $schema->getTable('share');
95
+            if (!$table->hasIndex('share_with_index')) {
96
+                $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>');
97
+                $table->addIndex(['share_with'], 'share_with_index');
98
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
99
+                $updated = true;
100
+                $output->writeln('<info>Share table updated successfully.</info>');
101
+            }
102
+
103
+            if (!$table->hasIndex('parent_index')) {
104
+                $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>');
105
+                $table->addIndex(['parent'], 'parent_index');
106
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
107
+                $updated = true;
108
+                $output->writeln('<info>Share table updated successfully.</info>');
109
+            }
110
+
111
+            if (!$table->hasIndex('owner_index')) {
112
+                $output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>');
113
+                $table->addIndex(['uid_owner'], 'owner_index');
114
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
115
+                $updated = true;
116
+                $output->writeln('<info>Share table updated successfully.</info>');
117
+            }
118
+
119
+            if (!$table->hasIndex('initiator_index')) {
120
+                $output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>');
121
+                $table->addIndex(['uid_initiator'], 'initiator_index');
122
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
123
+                $updated = true;
124
+                $output->writeln('<info>Share table updated successfully.</info>');
125
+            }
126
+        }
127
+
128
+        $output->writeln('<info>Check indices of the filecache table.</info>');
129
+        if ($schema->hasTable('filecache')) {
130
+            $table = $schema->getTable('filecache');
131
+            if (!$table->hasIndex('fs_mtime')) {
132
+                $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>');
133
+                $table->addIndex(['mtime'], 'fs_mtime');
134
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
135
+                $updated = true;
136
+                $output->writeln('<info>Filecache table updated successfully.</info>');
137
+            }
138
+        }
139
+
140
+        $output->writeln('<info>Check indices of the twofactor_providers table.</info>');
141
+        if ($schema->hasTable('twofactor_providers')) {
142
+            $table = $schema->getTable('twofactor_providers');
143
+            if (!$table->hasIndex('twofactor_providers_uid')) {
144
+                $output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>');
145
+                $table->addIndex(['uid'], 'twofactor_providers_uid');
146
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
147
+                $updated = true;
148
+                $output->writeln('<info>Twofactor_providers table updated successfully.</info>');
149
+            }
150
+        }
151
+
152
+        $output->writeln('<info>Check indices of the login_flow_v2 table.</info>');
153
+        if ($schema->hasTable('login_flow_v2')) {
154
+            $table = $schema->getTable('login_flow_v2');
155
+            if (!$table->hasIndex('poll_token')) {
156
+                $output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>');
157
+
158
+                foreach ($table->getIndexes() as $index) {
159
+                    $columns = $index->getColumns();
160
+                    if ($columns === ['poll_token'] ||
161
+                        $columns === ['login_token'] ||
162
+                        $columns === ['timestamp']) {
163
+                        $table->dropIndex($index->getName());
164
+                    }
165
+                }
166
+
167
+                $table->addUniqueIndex(['poll_token'], 'poll_token');
168
+                $table->addUniqueIndex(['login_token'], 'login_token');
169
+                $table->addIndex(['timestamp'], 'timestamp');
170
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
171
+                $updated = true;
172
+                $output->writeln('<info>login_flow_v2 table updated successfully.</info>');
173
+            }
174
+        }
175
+
176
+        $output->writeln('<info>Check indices of the whats_new table.</info>');
177
+        if ($schema->hasTable('whats_new')) {
178
+            $table = $schema->getTable('whats_new');
179
+            if (!$table->hasIndex('version')) {
180
+                $output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>');
181
+
182
+                foreach ($table->getIndexes() as $index) {
183
+                    if ($index->getColumns() === ['version']) {
184
+                        $table->dropIndex($index->getName());
185
+                    }
186
+                }
187
+
188
+                $table->addUniqueIndex(['version'], 'version');
189
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
190
+                $updated = true;
191
+                $output->writeln('<info>whats_new table updated successfully.</info>');
192
+            }
193
+        }
194
+
195
+        $output->writeln('<info>Check indices of the cards table.</info>');
196
+        if ($schema->hasTable('cards')) {
197
+            $table = $schema->getTable('cards');
198
+            if (!$table->hasIndex('cards_abid')) {
199
+                $output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>');
200
+
201
+                foreach ($table->getIndexes() as $index) {
202
+                    if ($index->getColumns() === ['addressbookid']) {
203
+                        $table->dropIndex($index->getName());
204
+                    }
205
+                }
206
+
207
+                $table->addIndex(['addressbookid'], 'cards_abid');
208
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
209
+                $updated = true;
210
+                $output->writeln('<info>cards table updated successfully.</info>');
211
+            }
212
+        }
213
+
214
+        $output->writeln('<info>Check indices of the cards_properties table.</info>');
215
+        if ($schema->hasTable('cards_properties')) {
216
+            $table = $schema->getTable('cards_properties');
217
+            if (!$table->hasIndex('cards_prop_abid')) {
218
+                $output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>');
219
+
220
+                foreach ($table->getIndexes() as $index) {
221
+                    if ($index->getColumns() === ['addressbookid']) {
222
+                        $table->dropIndex($index->getName());
223
+                    }
224
+                }
225
+
226
+                $table->addIndex(['addressbookid'], 'cards_prop_abid');
227
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
228
+                $updated = true;
229
+                $output->writeln('<info>cards_properties table updated successfully.</info>');
230
+            }
231
+        }
232
+
233
+        $output->writeln('<info>Check indices of the calendarobjects_props table.</info>');
234
+        if ($schema->hasTable('calendarobjects_props')) {
235
+            $table = $schema->getTable('calendarobjects_props');
236
+            if (!$table->hasIndex('calendarobject_calid_index')) {
237
+                $output->writeln('<info>Adding calendarobject_calid_index index to the calendarobjects_props table, this can take some time...</info>');
238
+
239
+                $table->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
240
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
241
+                $updated = true;
242
+                $output->writeln('<info>calendarobjects_props table updated successfully.</info>');
243
+            }
244
+        }
245
+
246
+        $output->writeln('<info>Check indices of the schedulingobjects table.</info>');
247
+        if ($schema->hasTable('schedulingobjects')) {
248
+            $table = $schema->getTable('schedulingobjects');
249
+            if (!$table->hasIndex('schedulobj_principuri_index')) {
250
+                $output->writeln('<info>Adding schedulobj_principuri_index index to the schedulingobjects table, this can take some time...</info>');
251
+
252
+                $table->addIndex(['principaluri'], 'schedulobj_principuri_index');
253
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
254
+                $updated = true;
255
+                $output->writeln('<info>schedulingobjects table updated successfully.</info>');
256
+            }
257
+        }
258
+
259
+        $output->writeln('<info>Check indices of the oc_properties table.</info>');
260
+        if ($schema->hasTable('properties')) {
261
+            $table = $schema->getTable('properties');
262
+            if (!$table->hasIndex('properties_path_index')) {
263
+                $output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
264
+
265
+                $table->addIndex(['userid', 'propertypath'], 'properties_path_index');
266
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
267
+                $updated = true;
268
+                $output->writeln('<info>oc_properties table updated successfully.</info>');
269
+            }
270
+        }
271
+
272
+        if (!$updated) {
273
+            $output->writeln('<info>Done.</info>');
274
+        }
275
+    }
276 276
 }
Please login to merge, or discard this patch.
core/Command/Db/AddMissingColumns.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -44,62 +44,62 @@
 block discarded – undo
44 44
  */
45 45
 class AddMissingColumns extends Command {
46 46
 
47
-	/** @var IDBConnection */
48
-	private $connection;
49
-
50
-	/** @var EventDispatcherInterface */
51
-	private $dispatcher;
52
-
53
-	public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
54
-		parent::__construct();
55
-
56
-		$this->connection = $connection;
57
-		$this->dispatcher = $dispatcher;
58
-	}
59
-
60
-	protected function configure() {
61
-		$this
62
-			->setName('db:add-missing-columns')
63
-			->setDescription('Add missing optional columns to the database tables');
64
-	}
65
-
66
-	protected function execute(InputInterface $input, OutputInterface $output): int {
67
-		$this->addCoreColumns($output);
68
-
69
-		// Dispatch event so apps can also update columns if needed
70
-		$event = new GenericEvent($output);
71
-		$this->dispatcher->dispatch(IDBConnection::ADD_MISSING_COLUMNS_EVENT, $event);
72
-		return 0;
73
-	}
74
-
75
-	/**
76
-	 * add missing indices to the share table
77
-	 *
78
-	 * @param OutputInterface $output
79
-	 * @throws \Doctrine\DBAL\Schema\SchemaException
80
-	 */
81
-	private function addCoreColumns(OutputInterface $output) {
82
-		$output->writeln('<info>Check columns of the comments table.</info>');
83
-
84
-		$schema = new SchemaWrapper($this->connection);
85
-		$updated = false;
86
-
87
-		if ($schema->hasTable('comments')) {
88
-			$table = $schema->getTable('comments');
89
-			if (!$table->hasColumn('reference_id')) {
90
-				$output->writeln('<info>Adding additional reference_id column to the comments table, this can take some time...</info>');
91
-				$table->addColumn('reference_id', 'string', [
92
-					'notnull' => false,
93
-					'length' => 64,
94
-				]);
95
-				$this->connection->migrateToSchema($schema->getWrappedSchema());
96
-				$updated = true;
97
-				$output->writeln('<info>Comments table updated successfully.</info>');
98
-			}
99
-		}
100
-
101
-		if (!$updated) {
102
-			$output->writeln('<info>Done.</info>');
103
-		}
104
-	}
47
+    /** @var IDBConnection */
48
+    private $connection;
49
+
50
+    /** @var EventDispatcherInterface */
51
+    private $dispatcher;
52
+
53
+    public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) {
54
+        parent::__construct();
55
+
56
+        $this->connection = $connection;
57
+        $this->dispatcher = $dispatcher;
58
+    }
59
+
60
+    protected function configure() {
61
+        $this
62
+            ->setName('db:add-missing-columns')
63
+            ->setDescription('Add missing optional columns to the database tables');
64
+    }
65
+
66
+    protected function execute(InputInterface $input, OutputInterface $output): int {
67
+        $this->addCoreColumns($output);
68
+
69
+        // Dispatch event so apps can also update columns if needed
70
+        $event = new GenericEvent($output);
71
+        $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_COLUMNS_EVENT, $event);
72
+        return 0;
73
+    }
74
+
75
+    /**
76
+     * add missing indices to the share table
77
+     *
78
+     * @param OutputInterface $output
79
+     * @throws \Doctrine\DBAL\Schema\SchemaException
80
+     */
81
+    private function addCoreColumns(OutputInterface $output) {
82
+        $output->writeln('<info>Check columns of the comments table.</info>');
83
+
84
+        $schema = new SchemaWrapper($this->connection);
85
+        $updated = false;
86
+
87
+        if ($schema->hasTable('comments')) {
88
+            $table = $schema->getTable('comments');
89
+            if (!$table->hasColumn('reference_id')) {
90
+                $output->writeln('<info>Adding additional reference_id column to the comments table, this can take some time...</info>');
91
+                $table->addColumn('reference_id', 'string', [
92
+                    'notnull' => false,
93
+                    'length' => 64,
94
+                ]);
95
+                $this->connection->migrateToSchema($schema->getWrappedSchema());
96
+                $updated = true;
97
+                $output->writeln('<info>Comments table updated successfully.</info>');
98
+            }
99
+        }
100
+
101
+        if (!$updated) {
102
+            $output->writeln('<info>Done.</info>');
103
+        }
104
+    }
105 105
 }
Please login to merge, or discard this patch.
core/Command/Config/ListConfigs.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -32,128 +32,128 @@
 block discarded – undo
32 32
 use Symfony\Component\Console\Output\OutputInterface;
33 33
 
34 34
 class ListConfigs extends Base {
35
-	protected $defaultOutputFormat = self::OUTPUT_FORMAT_JSON_PRETTY;
36
-
37
-	/** * @var SystemConfig */
38
-	protected $systemConfig;
39
-
40
-	/** @var IAppConfig */
41
-	protected $appConfig;
42
-
43
-	/**
44
-	 * @param SystemConfig $systemConfig
45
-	 * @param IAppConfig $appConfig
46
-	 */
47
-	public function __construct(SystemConfig $systemConfig, IAppConfig $appConfig) {
48
-		parent::__construct();
49
-		$this->systemConfig = $systemConfig;
50
-		$this->appConfig = $appConfig;
51
-	}
52
-
53
-	protected function configure() {
54
-		parent::configure();
55
-
56
-		$this
57
-			->setName('config:list')
58
-			->setDescription('List all configs')
59
-			->addArgument(
60
-				'app',
61
-				InputArgument::OPTIONAL,
62
-				'Name of the app ("system" to get the config.php values, "all" for all apps and system)',
63
-				'all'
64
-			)
65
-			->addOption(
66
-				'private',
67
-				null,
68
-				InputOption::VALUE_NONE,
69
-				'Use this option when you want to include sensitive configs like passwords, salts, ...'
70
-			)
71
-		;
72
-	}
73
-
74
-	protected function execute(InputInterface $input, OutputInterface $output): int {
75
-		$app = $input->getArgument('app');
76
-		$noSensitiveValues = !$input->getOption('private');
77
-
78
-		switch ($app) {
79
-			case 'system':
80
-				$configs = [
81
-					'system' => $this->getSystemConfigs($noSensitiveValues),
82
-				];
83
-			break;
84
-
85
-			case 'all':
86
-				$apps = $this->appConfig->getApps();
87
-				$configs = [
88
-					'system' => $this->getSystemConfigs($noSensitiveValues),
89
-					'apps' => [],
90
-				];
91
-				foreach ($apps as $appName) {
92
-					$configs['apps'][$appName] = $this->getAppConfigs($appName, $noSensitiveValues);
93
-				}
94
-			break;
95
-
96
-			default:
97
-				$configs = [
98
-					'apps' => [
99
-						$app => $this->getAppConfigs($app, $noSensitiveValues),
100
-					],
101
-				];
102
-		}
103
-
104
-		$this->writeArrayInOutputFormat($input, $output, $configs);
105
-		return 0;
106
-	}
107
-
108
-	/**
109
-	 * Get the system configs
110
-	 *
111
-	 * @param bool $noSensitiveValues
112
-	 * @return array
113
-	 */
114
-	protected function getSystemConfigs($noSensitiveValues) {
115
-		$keys = $this->systemConfig->getKeys();
116
-
117
-		$configs = [];
118
-		foreach ($keys as $key) {
119
-			if ($noSensitiveValues) {
120
-				$value = $this->systemConfig->getFilteredValue($key, serialize(null));
121
-			} else {
122
-				$value = $this->systemConfig->getValue($key, serialize(null));
123
-			}
124
-
125
-			if ($value !== 'N;') {
126
-				$configs[$key] = $value;
127
-			}
128
-		}
129
-
130
-		return $configs;
131
-	}
132
-
133
-	/**
134
-	 * Get the app configs
135
-	 *
136
-	 * @param string $app
137
-	 * @param bool $noSensitiveValues
138
-	 * @return array
139
-	 */
140
-	protected function getAppConfigs($app, $noSensitiveValues) {
141
-		if ($noSensitiveValues) {
142
-			return $this->appConfig->getFilteredValues($app, false);
143
-		} else {
144
-			return $this->appConfig->getValues($app, false);
145
-		}
146
-	}
147
-
148
-	/**
149
-	 * @param string $argumentName
150
-	 * @param CompletionContext $context
151
-	 * @return string[]
152
-	 */
153
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
154
-		if ($argumentName === 'app') {
155
-			return array_merge(['all', 'system'], \OC_App::getAllApps());
156
-		}
157
-		return [];
158
-	}
35
+    protected $defaultOutputFormat = self::OUTPUT_FORMAT_JSON_PRETTY;
36
+
37
+    /** * @var SystemConfig */
38
+    protected $systemConfig;
39
+
40
+    /** @var IAppConfig */
41
+    protected $appConfig;
42
+
43
+    /**
44
+     * @param SystemConfig $systemConfig
45
+     * @param IAppConfig $appConfig
46
+     */
47
+    public function __construct(SystemConfig $systemConfig, IAppConfig $appConfig) {
48
+        parent::__construct();
49
+        $this->systemConfig = $systemConfig;
50
+        $this->appConfig = $appConfig;
51
+    }
52
+
53
+    protected function configure() {
54
+        parent::configure();
55
+
56
+        $this
57
+            ->setName('config:list')
58
+            ->setDescription('List all configs')
59
+            ->addArgument(
60
+                'app',
61
+                InputArgument::OPTIONAL,
62
+                'Name of the app ("system" to get the config.php values, "all" for all apps and system)',
63
+                'all'
64
+            )
65
+            ->addOption(
66
+                'private',
67
+                null,
68
+                InputOption::VALUE_NONE,
69
+                'Use this option when you want to include sensitive configs like passwords, salts, ...'
70
+            )
71
+        ;
72
+    }
73
+
74
+    protected function execute(InputInterface $input, OutputInterface $output): int {
75
+        $app = $input->getArgument('app');
76
+        $noSensitiveValues = !$input->getOption('private');
77
+
78
+        switch ($app) {
79
+            case 'system':
80
+                $configs = [
81
+                    'system' => $this->getSystemConfigs($noSensitiveValues),
82
+                ];
83
+            break;
84
+
85
+            case 'all':
86
+                $apps = $this->appConfig->getApps();
87
+                $configs = [
88
+                    'system' => $this->getSystemConfigs($noSensitiveValues),
89
+                    'apps' => [],
90
+                ];
91
+                foreach ($apps as $appName) {
92
+                    $configs['apps'][$appName] = $this->getAppConfigs($appName, $noSensitiveValues);
93
+                }
94
+            break;
95
+
96
+            default:
97
+                $configs = [
98
+                    'apps' => [
99
+                        $app => $this->getAppConfigs($app, $noSensitiveValues),
100
+                    ],
101
+                ];
102
+        }
103
+
104
+        $this->writeArrayInOutputFormat($input, $output, $configs);
105
+        return 0;
106
+    }
107
+
108
+    /**
109
+     * Get the system configs
110
+     *
111
+     * @param bool $noSensitiveValues
112
+     * @return array
113
+     */
114
+    protected function getSystemConfigs($noSensitiveValues) {
115
+        $keys = $this->systemConfig->getKeys();
116
+
117
+        $configs = [];
118
+        foreach ($keys as $key) {
119
+            if ($noSensitiveValues) {
120
+                $value = $this->systemConfig->getFilteredValue($key, serialize(null));
121
+            } else {
122
+                $value = $this->systemConfig->getValue($key, serialize(null));
123
+            }
124
+
125
+            if ($value !== 'N;') {
126
+                $configs[$key] = $value;
127
+            }
128
+        }
129
+
130
+        return $configs;
131
+    }
132
+
133
+    /**
134
+     * Get the app configs
135
+     *
136
+     * @param string $app
137
+     * @param bool $noSensitiveValues
138
+     * @return array
139
+     */
140
+    protected function getAppConfigs($app, $noSensitiveValues) {
141
+        if ($noSensitiveValues) {
142
+            return $this->appConfig->getFilteredValues($app, false);
143
+        } else {
144
+            return $this->appConfig->getValues($app, false);
145
+        }
146
+    }
147
+
148
+    /**
149
+     * @param string $argumentName
150
+     * @param CompletionContext $context
151
+     * @return string[]
152
+     */
153
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
154
+        if ($argumentName === 'app') {
155
+            return array_merge(['all', 'system'], \OC_App::getAllApps());
156
+        }
157
+        return [];
158
+    }
159 159
 }
Please login to merge, or discard this patch.
core/Command/Config/App/SetConfig.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,61 +29,61 @@
 block discarded – undo
29 29
 use Symfony\Component\Console\Output\OutputInterface;
30 30
 
31 31
 class SetConfig extends Base {
32
-	/** * @var IConfig */
33
-	protected $config;
32
+    /** * @var IConfig */
33
+    protected $config;
34 34
 
35
-	/**
36
-	 * @param IConfig $config
37
-	 */
38
-	public function __construct(IConfig $config) {
39
-		parent::__construct();
40
-		$this->config = $config;
41
-	}
35
+    /**
36
+     * @param IConfig $config
37
+     */
38
+    public function __construct(IConfig $config) {
39
+        parent::__construct();
40
+        $this->config = $config;
41
+    }
42 42
 
43
-	protected function configure() {
44
-		parent::configure();
43
+    protected function configure() {
44
+        parent::configure();
45 45
 
46
-		$this
47
-			->setName('config:app:set')
48
-			->setDescription('Set an app config value')
49
-			->addArgument(
50
-				'app',
51
-				InputArgument::REQUIRED,
52
-				'Name of the app'
53
-			)
54
-			->addArgument(
55
-				'name',
56
-				InputArgument::REQUIRED,
57
-				'Name of the config to set'
58
-			)
59
-			->addOption(
60
-				'value',
61
-				null,
62
-				InputOption::VALUE_REQUIRED,
63
-				'The new value of the config'
64
-			)
65
-			->addOption(
66
-				'update-only',
67
-				null,
68
-				InputOption::VALUE_NONE,
69
-				'Only updates the value, if it is not set before, it is not being added'
70
-			)
71
-		;
72
-	}
46
+        $this
47
+            ->setName('config:app:set')
48
+            ->setDescription('Set an app config value')
49
+            ->addArgument(
50
+                'app',
51
+                InputArgument::REQUIRED,
52
+                'Name of the app'
53
+            )
54
+            ->addArgument(
55
+                'name',
56
+                InputArgument::REQUIRED,
57
+                'Name of the config to set'
58
+            )
59
+            ->addOption(
60
+                'value',
61
+                null,
62
+                InputOption::VALUE_REQUIRED,
63
+                'The new value of the config'
64
+            )
65
+            ->addOption(
66
+                'update-only',
67
+                null,
68
+                InputOption::VALUE_NONE,
69
+                'Only updates the value, if it is not set before, it is not being added'
70
+            )
71
+        ;
72
+    }
73 73
 
74
-	protected function execute(InputInterface $input, OutputInterface $output): int {
75
-		$appName = $input->getArgument('app');
76
-		$configName = $input->getArgument('name');
74
+    protected function execute(InputInterface $input, OutputInterface $output): int {
75
+        $appName = $input->getArgument('app');
76
+        $configName = $input->getArgument('name');
77 77
 
78
-		if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) {
79
-			$output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>');
80
-			return 1;
81
-		}
78
+        if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) {
79
+            $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>');
80
+            return 1;
81
+        }
82 82
 
83
-		$configValue = $input->getOption('value');
84
-		$this->config->setAppValue($appName, $configName, $configValue);
83
+        $configValue = $input->getOption('value');
84
+        $this->config->setAppValue($appName, $configName, $configValue);
85 85
 
86
-		$output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>');
87
-		return 0;
88
-	}
86
+        $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>');
87
+        return 0;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
core/Command/Config/App/GetConfig.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -29,65 +29,65 @@
 block discarded – undo
29 29
 use Symfony\Component\Console\Output\OutputInterface;
30 30
 
31 31
 class GetConfig extends Base {
32
-	/** * @var IConfig */
33
-	protected $config;
32
+    /** * @var IConfig */
33
+    protected $config;
34 34
 
35
-	/**
36
-	 * @param IConfig $config
37
-	 */
38
-	public function __construct(IConfig $config) {
39
-		parent::__construct();
40
-		$this->config = $config;
41
-	}
35
+    /**
36
+     * @param IConfig $config
37
+     */
38
+    public function __construct(IConfig $config) {
39
+        parent::__construct();
40
+        $this->config = $config;
41
+    }
42 42
 
43
-	protected function configure() {
44
-		parent::configure();
43
+    protected function configure() {
44
+        parent::configure();
45 45
 
46
-		$this
47
-			->setName('config:app:get')
48
-			->setDescription('Get an app config value')
49
-			->addArgument(
50
-				'app',
51
-				InputArgument::REQUIRED,
52
-				'Name of the app'
53
-			)
54
-			->addArgument(
55
-				'name',
56
-				InputArgument::REQUIRED,
57
-				'Name of the config to get'
58
-			)
59
-			->addOption(
60
-				'default-value',
61
-				null,
62
-				InputOption::VALUE_OPTIONAL,
63
-				'If no default value is set and the config does not exist, the command will exit with 1'
64
-			)
65
-		;
66
-	}
46
+        $this
47
+            ->setName('config:app:get')
48
+            ->setDescription('Get an app config value')
49
+            ->addArgument(
50
+                'app',
51
+                InputArgument::REQUIRED,
52
+                'Name of the app'
53
+            )
54
+            ->addArgument(
55
+                'name',
56
+                InputArgument::REQUIRED,
57
+                'Name of the config to get'
58
+            )
59
+            ->addOption(
60
+                'default-value',
61
+                null,
62
+                InputOption::VALUE_OPTIONAL,
63
+                'If no default value is set and the config does not exist, the command will exit with 1'
64
+            )
65
+        ;
66
+    }
67 67
 
68
-	/**
69
-	 * Executes the current command.
70
-	 *
71
-	 * @param InputInterface  $input  An InputInterface instance
72
-	 * @param OutputInterface $output An OutputInterface instance
73
-	 * @return null|int null or 0 if everything went fine, or an error code
74
-	 */
75
-	protected function execute(InputInterface $input, OutputInterface $output): int {
76
-		$appName = $input->getArgument('app');
77
-		$configName = $input->getArgument('name');
78
-		$defaultValue = $input->getOption('default-value');
68
+    /**
69
+     * Executes the current command.
70
+     *
71
+     * @param InputInterface  $input  An InputInterface instance
72
+     * @param OutputInterface $output An OutputInterface instance
73
+     * @return null|int null or 0 if everything went fine, or an error code
74
+     */
75
+    protected function execute(InputInterface $input, OutputInterface $output): int {
76
+        $appName = $input->getArgument('app');
77
+        $configName = $input->getArgument('name');
78
+        $defaultValue = $input->getOption('default-value');
79 79
 
80
-		if (!in_array($configName, $this->config->getAppKeys($appName)) && !$input->hasParameterOption('--default-value')) {
81
-			return 1;
82
-		}
80
+        if (!in_array($configName, $this->config->getAppKeys($appName)) && !$input->hasParameterOption('--default-value')) {
81
+            return 1;
82
+        }
83 83
 
84
-		if (!in_array($configName, $this->config->getAppKeys($appName))) {
85
-			$configValue = $defaultValue;
86
-		} else {
87
-			$configValue = $this->config->getAppValue($appName, $configName);
88
-		}
84
+        if (!in_array($configName, $this->config->getAppKeys($appName))) {
85
+            $configValue = $defaultValue;
86
+        } else {
87
+            $configValue = $this->config->getAppValue($appName, $configName);
88
+        }
89 89
 
90
-		$this->writeMixedInOutputFormat($input, $output, $configValue);
91
-		return 0;
92
-	}
90
+        $this->writeMixedInOutputFormat($input, $output, $configValue);
91
+        return 0;
92
+    }
93 93
 }
Please login to merge, or discard this patch.