@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->writeResults($results, $time); |
49 | 49 | |
50 | - return (int)$results['failed']; |
|
50 | + return (int) $results['failed']; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->executeSqlAction( |
61 | 61 | $instanceList, |
62 | 62 | 'Listing of users', |
63 | - function ($schemaManager, $instanceName) { |
|
63 | + function($schemaManager, $instanceName) { |
|
64 | 64 | /** @var DatabaseSchemaManager $schemaManager */ |
65 | 65 | return $schemaManager->getListUsersSqlAction(); |
66 | 66 | } |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | |
82 | 82 | /// @todo inject more randomness in the username, by allowing more chars than bin2hex produces |
83 | 83 | |
84 | - $userName = 'db3v4l_' . substr(bin2hex(random_bytes(5)), 0, 9); // some mysql versions have a limitation of 16 chars for usernames |
|
84 | + $userName = 'db3v4l_'.substr(bin2hex(random_bytes(5)), 0, 9); // some mysql versions have a limitation of 16 chars for usernames |
|
85 | 85 | $password = bin2hex(random_bytes(16)); |
86 | 86 | //$dbName = bin2hex(random_bytes(31)); |
87 | 87 | $dbName = $userName; // $userName will be used as db name |
88 | 88 | |
89 | 89 | $tempDbSpecs = []; |
90 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
90 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
91 | 91 | $tempDbSpecs[$instanceName] = [ |
92 | 92 | 'dbname' => $dbName, |
93 | 93 | 'user' => $userName, |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | if (($charset = $input->getOption('charset')) != '') { |
99 | - foreach($instanceList as $instanceName) { |
|
99 | + foreach ($instanceList as $instanceName) { |
|
100 | 100 | $tempDbSpecs[$instanceName]['charset'] = $charset; |
101 | 101 | } |
102 | 102 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | ]; |
119 | 119 | |
120 | 120 | $dbConnectionSpecs = []; |
121 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
121 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
122 | 122 | $dbConnectionSpecs[$instanceName] = array_merge($instanceSpecs, $dbConfig); |
123 | 123 | } |
124 | 124 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | if ($createDB) { |
134 | 134 | $results['failed'] += $creationResults['failed']; |
135 | 135 | |
136 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
136 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
137 | 137 | if (!isset($dbConnectionSpecs[$instanceName])) { |
138 | 138 | unset($instanceList[$instanceName]); |
139 | 139 | } |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | $this->dropDatabases($instanceList, $dbConnectionSpecs, true); |
142 | 142 | } |
143 | 143 | } else { |
144 | - $results = ['succeeded' => 0, 'failed' => 0, 'data' => null]; |
|
144 | + $results = ['succeeded' => 0, 'failed' => 0, 'data' => null]; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $time = microtime(true) - $start; |
148 | 148 | |
149 | 149 | $this->writeResults($results, $time); |
150 | 150 | |
151 | - return (int)$results['failed']; |
|
151 | + return (int) $results['failed']; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | return $this->executeSqlAction( |
167 | 167 | $dbConnectionSpecs, |
168 | 168 | 'Execution of SQL', |
169 | - function ($schemaManager, $instanceName) use ($sql, $filename) { |
|
169 | + function($schemaManager, $instanceName) use ($sql, $filename) { |
|
170 | 170 | if ($sql != null) { |
171 | 171 | return new Command( |
172 | 172 | $sql, |
173 | - function ($output, $executor) { |
|
173 | + function($output, $executor) { |
|
174 | 174 | /** @var TimedExecutor $executor */ |
175 | 175 | return array_merge(['stdout' => $output], $executor->getTimingData()); |
176 | 176 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | return new File( |
185 | 185 | $realFileName, |
186 | - function ($output, $executor) { |
|
186 | + function($output, $executor) { |
|
187 | 187 | /** @var TimedExecutor $executor */ |
188 | 188 | return array_merge(['stdout' => $output], $executor->getTimingData()); |
189 | 189 | } |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | if (trim($line) !== '') { |
219 | 219 | if ($type === 'err') { |
220 | 220 | $this->writeErrorln( |
221 | - '[' . $processIndex . '][' . $pid . '] ' . trim($line), |
|
221 | + '['.$processIndex.']['.$pid.'] '.trim($line), |
|
222 | 222 | OutputInterface::VERBOSITY_VERBOSE, |
223 | 223 | OutputInterface::OUTPUT_RAW |
224 | 224 | ); |
225 | 225 | } else { |
226 | 226 | $this->writeln( |
227 | - '[' . $processIndex . '][' . $pid . '] ' . trim($line), |
|
227 | + '['.$processIndex.']['.$pid.'] '.trim($line), |
|
228 | 228 | OutputInterface::VERBOSITY_VERBOSE, |
229 | 229 | OutputInterface::OUTPUT_RAW |
230 | 230 | ); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->writeResults($results, $time); |
49 | 49 | |
50 | - return (int)$results['failed']; |
|
50 | + return (int) $results['failed']; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->executeSqlAction( |
61 | 61 | $instanceList, |
62 | 62 | 'Listing of collations', |
63 | - function ($schemaManager, $instanceName) { |
|
63 | + function($schemaManager, $instanceName) { |
|
64 | 64 | /** @var DatabaseSchemaManager $schemaManager */ |
65 | 65 | return $schemaManager->getListCollationsSqlAction(); |
66 | 66 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->writeResults($results, $time); |
49 | 49 | |
50 | - return (int)$results['failed']; |
|
50 | + return (int) $results['failed']; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->executeSqlAction( |
61 | 61 | $instanceList, |
62 | 62 | 'Listing of databases', |
63 | - function ($schemaManager, $instanceName) { |
|
63 | + function($schemaManager, $instanceName) { |
|
64 | 64 | /** @var DatabaseSchemaManager $schemaManager */ |
65 | 65 | return $schemaManager->getListDatabasesSqlAction(); |
66 | 66 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | $userToDropSpecs = []; |
53 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
53 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
54 | 54 | $userToDropSpecs[$instanceName] = [ |
55 | 55 | 'user' => $userName |
56 | 56 | ]; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $this->writeResults($results, $time); |
66 | 66 | |
67 | - return (int)$results['failed']; |
|
67 | + return (int) $results['failed']; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return $this->executeSqlAction( |
80 | 80 | $instanceList, |
81 | 81 | 'Dropping of user', |
82 | - function ($schemaManager, $instanceName) use ($userToDropSpecs, $ifExists) { |
|
82 | + function($schemaManager, $instanceName) use ($userToDropSpecs, $ifExists) { |
|
83 | 83 | $dbConnectionSpec = $userToDropSpecs[$instanceName]; |
84 | 84 | /** @var DatabaseSchemaManager $schemaManager */ |
85 | 85 | return $schemaManager->getDropUserSqlAction( |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $results = $this->executeSqlAction( |
21 | 21 | $instanceList, |
22 | 22 | 'Creating new database & user', |
23 | - function ($schemaManager, $instanceName) use ($dbSpecList) { |
|
23 | + function($schemaManager, $instanceName) use ($dbSpecList) { |
|
24 | 24 | $dbConnectionSpec = $dbSpecList[$instanceName]; |
25 | 25 | /** @var DatabaseSchemaManager $schemaManager */ |
26 | 26 | return $schemaManager->getCreateDatabaseSqlAction( |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | ); |
34 | 34 | |
35 | 35 | $finalData = []; |
36 | - foreach($results['data'] as $instanceName => $data) { |
|
36 | + foreach ($results['data'] as $instanceName => $data) { |
|
37 | 37 | $dbConnectionSpec = $dbSpecList[$instanceName]; |
38 | 38 | $finalData[$instanceName] = $instanceList[$instanceName]; |
39 | 39 | $finalData[$instanceName]['dbname'] = $dbConnectionSpec['dbname']; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return $this->executeSqlAction( |
65 | 65 | $instanceList, |
66 | 66 | 'Dropping of database & user', |
67 | - function ($schemaManager, $instanceName) use ($dbSpecList, $ifExists) { |
|
67 | + function($schemaManager, $instanceName) use ($dbSpecList, $ifExists) { |
|
68 | 68 | $dbConnectionSpec = $dbSpecList[$instanceName]; |
69 | 69 | /** @var DatabaseSchemaManager $schemaManager */ |
70 | 70 | return $schemaManager->getDropDatabaseSqlAction( |
@@ -52,7 +52,7 @@ |
||
52 | 52 | } |
53 | 53 | $executor = $this->executorFactory->createForkedExecutor($dbConnectionSpec, 'NativeClient', false); |
54 | 54 | |
55 | - if (! $executor instanceof ShellExecutor) { |
|
55 | + if (!$executor instanceof ShellExecutor) { |
|
56 | 56 | throw new \Exception("Can not start an interactive shell for databases of type '{$dbConnectionSpec['vendor']}'"); |
57 | 57 | } |
58 | 58 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $result = $this->listInstances($instanceList); |
38 | 38 | |
39 | 39 | $extraResults = $this->listDatabasesVersion($instanceList)['data']; |
40 | - foreach($result as $instanceName => $instanceDesc) { |
|
40 | + foreach ($result as $instanceName => $instanceDesc) { |
|
41 | 41 | if (isset($extraResults[$instanceName])) { |
42 | 42 | $result[$instanceName]['version'] = $extraResults[$instanceName]; |
43 | 43 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | protected function listInstances($instanceList) |
57 | 57 | { |
58 | 58 | $out = []; |
59 | - foreach($instanceList as $instanceName => $connectionSpec) { |
|
59 | + foreach ($instanceList as $instanceName => $connectionSpec) { |
|
60 | 60 | //$connectionSpec = $this->dbConfigurationManager->getInstanceConfiguration($instanceName); |
61 | 61 | $out[$instanceName] = [ |
62 | 62 | 'vendor' => $connectionSpec['vendor'], |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return $this->executeSqlAction( |
72 | 72 | $instanceList, |
73 | 73 | 'Getting database version information', |
74 | - function ($schemaManager, $instanceName) { |
|
74 | + function($schemaManager, $instanceName) { |
|
75 | 75 | /** @var DatabaseSchemaManager $schemaManager */ |
76 | 76 | return $schemaManager->getRetrieveVersionInfoSqlAction(); |
77 | 77 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | file_put_contents($this->outputFile, $data); |
102 | 102 | $this->writeln("Results saved to file {$this->outputFile}"); |
103 | 103 | } else { |
104 | - $this->writeln($data, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
|
104 | + $this->writeln($data, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | protected function addCommonOptions() |
50 | 50 | { |
51 | 51 | $this |
52 | - ->addOption('only-instances', 'o', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against. Usage of * and ? wildcards is allowed. To see all instances available, use `instance:list`', null) |
|
53 | - ->addOption('except-instances', 'x', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against', null) |
|
52 | + ->addOption('only-instances', 'o', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against. Usage of * and ? wildcards is allowed. To see all instances available, use `instance:list`', null) |
|
53 | + ->addOption('except-instances', 'x', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against', null) |
|
54 | 54 | ->addOption('output-type', null, InputOption::VALUE_REQUIRED, 'The format for the output: json, php, text or yml', self::DEFAULT_OUTPUT_FORMAT) |
55 | 55 | ->addOption('output-file', null, InputOption::VALUE_REQUIRED, 'Save output to a file instead of writing it to stdout. NB: take care that dbconsole runs in a container, which has a different view of the filesystem. A good dir for output is ./shared') |
56 | 56 | ->addOption('timeout', null, InputOption::VALUE_REQUIRED, 'The maximum time to wait for subprocess execution (secs)', self::DEFAULT_PROCESS_TIMEOUT) |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | // On Debian, which we use by default, SF has troubles understanding that php was compiled with --enable-sigchild |
78 | 78 | // We thus force it, but give end users an option to disable this |
79 | 79 | // For more details, see comment 12 at https://bugs.launchpad.net/ubuntu/+source/php5/+bug/516061 |
80 | - if (! $input->getOption('dont-force-enabled-sigchild')) { |
|
80 | + if (!$input->getOption('dont-force-enabled-sigchild')) { |
|
81 | 81 | Process::forceSigchildEnabled(true); |
82 | 82 | } |
83 | 83 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $sql = null; |
122 | 122 | } else { |
123 | 123 | // this is a coding error, not a sql execution error |
124 | - throw new \Exception("Unsupported action type: " . get_class($sqlAction)); |
|
124 | + throw new \Exception("Unsupported action type: ".get_class($sqlAction)); |
|
125 | 125 | } |
126 | 126 | $filterCallable = $sqlAction->getResultsFilterCallable(); |
127 | 127 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $outputFilters[$instanceName] = $filterCallable; |
133 | 133 | |
134 | 134 | if ($filename === null && !$sqlAction->isSingleStatement()) { |
135 | - $filename = tempnam(sys_get_temp_dir(), 'db3v4l_') . '.sql'; |
|
135 | + $filename = tempnam(sys_get_temp_dir(), 'db3v4l_').'.sql'; |
|
136 | 136 | file_put_contents($filename, $sql); |
137 | 137 | $tempSQLFileNames[] = $filename; |
138 | 138 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | if ($this->outputFormat === 'text') { |
158 | - $this->writeln('Command line: ' . $process->getCommandLine(), OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
158 | + $this->writeln('Command line: '.$process->getCommandLine(), OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $process->setTimeout($this->processTimeout); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $succeeded++; |
178 | 178 | } catch (\Throwable $t) { |
179 | 179 | $failed++; |
180 | - $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $t->getMessage() . "</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
180 | + $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$t->getMessage()."</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | //$result = null; |
200 | 200 | $failed++; |
201 | 201 | $succeeded--; |
202 | - $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $t->getMessage() . "</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
202 | + $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$t->getMessage()."</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | $results[$instanceName] = $output; |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | 'exitcode' => $process->getExitCode() |
211 | 211 | ]; |
212 | 212 | $failed++; |
213 | - $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $process->getErrorOutput() . "</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
213 | + $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$process->getErrorOutput()."</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | 218 | } finally { |
219 | 219 | // make sure that we clean up temp files, as they might contain sensitive data |
220 | - foreach($tempSQLFileNames as $tempSQLFileName) { |
|
220 | + foreach ($tempSQLFileNames as $tempSQLFileName) { |
|
221 | 221 | unlink($tempSQLFileName); |
222 | 222 | } |
223 | 223 | } |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | if ($this->outputFile != null) { |
267 | 267 | file_put_contents($this->outputFile, $formattedResults); |
268 | 268 | } else { |
269 | - $this->writeln($formattedResults, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
|
269 | + $this->writeln($formattedResults, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | if ($this->outputFormat === 'text' || $this->outputFile != null) { |
273 | - $this->writeln($results['succeeded'] . ' succeeded, ' . $results['failed'] . ' failed'); |
|
273 | + $this->writeln($results['succeeded'].' succeeded, '.$results['failed'].' failed'); |
|
274 | 274 | if ($this->outputFile != null) { |
275 | 275 | $this->writeln("Results saved to file {$this->outputFile}"); |
276 | 276 | } |