@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $appName = $input->getArgument('app'); |
| 107 | 107 | $version = $input->getArgument('version'); |
| 108 | 108 | |
| 109 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 109 | + if (!preg_match('/^\d{1,16}$/', $version)) { |
|
| 110 | 110 | $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
| 111 | 111 | return 1; |
| 112 | 112 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
| 115 | 115 | |
| 116 | 116 | $date = date('YmdHis'); |
| 117 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
| 117 | + $path = $this->generateMigration($ms, 'Version'.$version.'Date'.$date); |
|
| 118 | 118 | |
| 119 | 119 | $output->writeln("New migration class has been generated to <info>$path</info>"); |
| 120 | 120 | return 0; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
| 130 | 130 | if ($schemaBody === '') { |
| 131 | - $schemaBody = "\t\t" . 'return null;'; |
|
| 131 | + $schemaBody = "\t\t".'return null;'; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $dir = $ms->getMigrationsDirectory(); |
| 147 | 147 | |
| 148 | 148 | $this->ensureMigrationDirExists($dir); |
| 149 | - $path = $dir . '/' . $className . '.php'; |
|
| 149 | + $path = $dir.'/'.$className.'.php'; |
|
| 150 | 150 | |
| 151 | 151 | if (file_put_contents($path, $code) === false) { |
| 152 | 152 | throw new RuntimeException('Failed to generate new migration step.'); |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function validate($config) { |
| 55 | 55 | $errors = array(); |
| 56 | - if(empty($config['dbuser']) && empty($config['dbname'])) { |
|
| 56 | + if (empty($config['dbuser']) && empty($config['dbname'])) { |
|
| 57 | 57 | $errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname)); |
| 58 | - } else if(empty($config['dbuser'])) { |
|
| 58 | + } else if (empty($config['dbuser'])) { |
|
| 59 | 59 | $errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname)); |
| 60 | - } else if(empty($config['dbname'])) { |
|
| 60 | + } else if (empty($config['dbname'])) { |
|
| 61 | 61 | $errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname)); |
| 62 | 62 | } |
| 63 | 63 | return $errors; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public function setupDatabase($username) { |
| 67 | 67 | $e_host = addslashes($this->dbHost); |
| 68 | 68 | // casting to int to avoid malicious input |
| 69 | - $e_port = (int)$this->dbPort; |
|
| 69 | + $e_port = (int) $this->dbPort; |
|
| 70 | 70 | $e_dbname = addslashes($this->dbName); |
| 71 | 71 | //check if the database user has admin right |
| 72 | 72 | if ($e_host == '') { |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | } else { |
| 75 | 75 | $easy_connect_string = '//'.$e_host.(!empty($e_port) ? ":{$e_port}" : "").'/'.$e_dbname; |
| 76 | 76 | } |
| 77 | - $this->logger->debug('connect string: ' . $easy_connect_string, ['app' => 'setup.oci']); |
|
| 77 | + $this->logger->debug('connect string: '.$easy_connect_string, ['app' => 'setup.oci']); |
|
| 78 | 78 | $connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string); |
| 79 | - if(!$connection) { |
|
| 79 | + if (!$connection) { |
|
| 80 | 80 | $errorMessage = $this->getLastError(); |
| 81 | 81 | if ($errorMessage) { |
| 82 | 82 | throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'), |
@@ -84,41 +84,41 @@ discard block |
||
| 84 | 84 | .' ORACLE_SID='.getenv('ORACLE_SID') |
| 85 | 85 | .' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH') |
| 86 | 86 | .' NLS_LANG='.getenv('NLS_LANG') |
| 87 | - .' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora')?'':'not ').'readable'); |
|
| 87 | + .' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora') ? '' : 'not ').'readable'); |
|
| 88 | 88 | } |
| 89 | 89 | throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), |
| 90 | 90 | 'Check environment: ORACLE_HOME='.getenv('ORACLE_HOME') |
| 91 | 91 | .' ORACLE_SID='.getenv('ORACLE_SID') |
| 92 | 92 | .' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH') |
| 93 | 93 | .' NLS_LANG='.getenv('NLS_LANG') |
| 94 | - .' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora')?'':'not ').'readable'); |
|
| 94 | + .' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora') ? '' : 'not ').'readable'); |
|
| 95 | 95 | } |
| 96 | 96 | //check for roles creation rights in oracle |
| 97 | 97 | |
| 98 | - $query='SELECT count(*) FROM user_role_privs, role_sys_privs' |
|
| 98 | + $query = 'SELECT count(*) FROM user_role_privs, role_sys_privs' |
|
| 99 | 99 | ." WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'"; |
| 100 | 100 | $stmt = oci_parse($connection, $query); |
| 101 | 101 | if (!$stmt) { |
| 102 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 103 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 102 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 103 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 104 | 104 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 105 | 105 | } |
| 106 | 106 | $result = oci_execute($stmt); |
| 107 | - if($result) { |
|
| 107 | + if ($result) { |
|
| 108 | 108 | $row = oci_fetch_row($stmt); |
| 109 | 109 | |
| 110 | 110 | if ($row[0] > 0) { |
| 111 | 111 | //use the admin login data for the new database user |
| 112 | 112 | |
| 113 | 113 | //add prefix to the oracle user name to prevent collisions |
| 114 | - $this->dbUser='oc_'.$username; |
|
| 114 | + $this->dbUser = 'oc_'.$username; |
|
| 115 | 115 | //create a new password so we don't need to store the admin config in the config file |
| 116 | 116 | $this->dbPassword = \OC::$server->getSecureRandom()->generate(30, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); |
| 117 | 117 | |
| 118 | 118 | //oracle passwords are treated as identifiers: |
| 119 | 119 | // must start with alphanumeric char |
| 120 | 120 | // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length. |
| 121 | - $this->dbPassword=substr($this->dbPassword, 0, 30); |
|
| 121 | + $this->dbPassword = substr($this->dbPassword, 0, 30); |
|
| 122 | 122 | |
| 123 | 123 | $this->createDBUser($connection); |
| 124 | 124 | } |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | if ($e_host == '') { |
| 150 | 150 | $easy_connect_string = $e_dbname; // use dbname as easy connect name |
| 151 | 151 | } else { |
| 152 | - $easy_connect_string = '//' . $e_host . (!empty($e_port) ? ":{$e_port}" : "") . '/' . $e_dbname; |
|
| 152 | + $easy_connect_string = '//'.$e_host.(!empty($e_port) ? ":{$e_port}" : "").'/'.$e_dbname; |
|
| 153 | 153 | } |
| 154 | 154 | $connection = @oci_connect($this->dbUser, $this->dbPassword, $easy_connect_string); |
| 155 | - if(!$connection) { |
|
| 155 | + if (!$connection) { |
|
| 156 | 156 | throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), |
| 157 | 157 | $this->trans->t('You need to enter details of an existing account.')); |
| 158 | 158 | } |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | $un = $this->tablePrefix.'users'; |
| 162 | 162 | oci_bind_by_name($stmt, ':un', $un); |
| 163 | 163 | if (!$stmt) { |
| 164 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 165 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 166 | - $this->logger->warning( $entry, ['app' => 'setup.oci']); |
|
| 164 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 165 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 166 | + $this->logger->warning($entry, ['app' => 'setup.oci']); |
|
| 167 | 167 | } |
| 168 | 168 | oci_execute($stmt); |
| 169 | 169 | } |
@@ -177,35 +177,35 @@ discard block |
||
| 177 | 177 | $query = "SELECT * FROM all_users WHERE USERNAME = :un"; |
| 178 | 178 | $stmt = oci_parse($connection, $query); |
| 179 | 179 | if (!$stmt) { |
| 180 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 181 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 180 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 181 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 182 | 182 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 183 | 183 | } |
| 184 | 184 | oci_bind_by_name($stmt, ':un', $name); |
| 185 | 185 | $result = oci_execute($stmt); |
| 186 | - if(!$result) { |
|
| 187 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 188 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 186 | + if (!$result) { |
|
| 187 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 188 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 189 | 189 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if(! oci_fetch_row($stmt)) { |
|
| 192 | + if (!oci_fetch_row($stmt)) { |
|
| 193 | 193 | //user does not exists let's create it :) |
| 194 | 194 | //password must start with alphabetic character in oracle |
| 195 | 195 | $query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$this->dbtablespace; |
| 196 | 196 | $stmt = oci_parse($connection, $query); |
| 197 | 197 | if (!$stmt) { |
| 198 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 199 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 198 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 199 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 200 | 200 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 201 | 201 | |
| 202 | 202 | } |
| 203 | 203 | //oci_bind_by_name($stmt, ':un', $name); |
| 204 | 204 | $result = oci_execute($stmt); |
| 205 | - if(!$result) { |
|
| 206 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 205 | + if (!$result) { |
|
| 206 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 207 | 207 | $entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s', |
| 208 | - array($query, $name, $password)) . '<br />'; |
|
| 208 | + array($query, $name, $password)).'<br />'; |
|
| 209 | 209 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 210 | 210 | |
| 211 | 211 | } |
@@ -213,16 +213,16 @@ discard block |
||
| 213 | 213 | $query = "ALTER USER :un IDENTIFIED BY :pw"; |
| 214 | 214 | $stmt = oci_parse($connection, $query); |
| 215 | 215 | if (!$stmt) { |
| 216 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 217 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 216 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 217 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 218 | 218 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 219 | 219 | } |
| 220 | 220 | oci_bind_by_name($stmt, ':un', $name); |
| 221 | 221 | oci_bind_by_name($stmt, ':pw', $password); |
| 222 | 222 | $result = oci_execute($stmt); |
| 223 | - if(!$result) { |
|
| 224 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 225 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 223 | + if (!$result) { |
|
| 224 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 225 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 226 | 226 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -230,15 +230,15 @@ discard block |
||
| 230 | 230 | $query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name; |
| 231 | 231 | $stmt = oci_parse($connection, $query); |
| 232 | 232 | if (!$stmt) { |
| 233 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 234 | - $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />'; |
|
| 233 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 234 | + $entry .= $this->trans->t('Offending command was: "%s"', array($query)).'<br />'; |
|
| 235 | 235 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 236 | 236 | } |
| 237 | 237 | $result = oci_execute($stmt); |
| 238 | - if(!$result) { |
|
| 239 | - $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />'; |
|
| 238 | + if (!$result) { |
|
| 239 | + $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))).'<br />'; |
|
| 240 | 240 | $entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s', |
| 241 | - array($query, $name, $password)) . '<br />'; |
|
| 241 | + array($query, $name, $password)).'<br />'; |
|
| 242 | 242 | $this->logger->warning($entry, ['app' => 'setup.oci']); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $this->createDatabase($connection); |
| 51 | 51 | |
| 52 | 52 | //fill the database if needed |
| 53 | - $query='select count(*) from information_schema.tables where table_schema=? AND table_name = ?'; |
|
| 53 | + $query = 'select count(*) from information_schema.tables where table_schema=? AND table_name = ?'; |
|
| 54 | 54 | $connection->executeQuery($query, [$this->dbName, $this->tablePrefix.'users']); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param \OC\DB\Connection $connection |
| 59 | 59 | */ |
| 60 | 60 | private function createDatabase($connection) { |
| 61 | - try{ |
|
| 61 | + try { |
|
| 62 | 62 | $name = $this->dbName; |
| 63 | 63 | $user = $this->dbUser; |
| 64 | 64 | //we can't use OC_DB functions here because we need to connect as the administrative user. |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | try { |
| 77 | 77 | //this query will fail if there aren't the right permissions, ignore the error |
| 78 | - $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; |
|
| 78 | + $query = "GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; |
|
| 79 | 79 | $connection->executeUpdate($query); |
| 80 | 80 | } catch (\Exception $ex) { |
| 81 | 81 | $this->logger->debug('Could not automatically grant privileges, this can be ignored if database user already had privileges: {error}', [ |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @throws \OC\DatabaseSetupException |
| 91 | 91 | */ |
| 92 | 92 | private function createDBUser($connection) { |
| 93 | - try{ |
|
| 93 | + try { |
|
| 94 | 94 | $name = $this->dbUser; |
| 95 | 95 | $password = $this->dbPassword; |
| 96 | 96 | // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one, |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; |
| 101 | 101 | $connection->executeUpdate($query); |
| 102 | 102 | } |
| 103 | - catch (\Exception $ex){ |
|
| 103 | + catch (\Exception $ex) { |
|
| 104 | 104 | $this->logger->error('Database User creation failed: {error}', [ |
| 105 | 105 | 'app' => 'mysql.setup', |
| 106 | 106 | 'error' => $ex->getMessage() |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | //we don't have a dbuser specified in config |
| 122 | 122 | if ($this->dbUser !== $oldUser) { |
| 123 | 123 | //add prefix to the admin username to prevent collisions |
| 124 | - $adminUser = substr('oc_' . $username, 0, 16); |
|
| 124 | + $adminUser = substr('oc_'.$username, 0, 16); |
|
| 125 | 125 | |
| 126 | 126 | $i = 1; |
| 127 | 127 | while (true) { |
@@ -138,15 +138,15 @@ discard block |
||
| 138 | 138 | $this->dbUser = $adminUser; |
| 139 | 139 | |
| 140 | 140 | //create a random password so we don't need to store the admin password in the config file |
| 141 | - $this->dbPassword = $this->random->generate(30); |
|
| 141 | + $this->dbPassword = $this->random->generate(30); |
|
| 142 | 142 | |
| 143 | 143 | $this->createDBUser($connection); |
| 144 | 144 | |
| 145 | 145 | break; |
| 146 | 146 | } else { |
| 147 | 147 | //repeat with different username |
| 148 | - $length = strlen((string)$i); |
|
| 149 | - $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i; |
|
| 148 | + $length = strlen((string) $i); |
|
| 149 | + $adminUser = substr('oc_'.$username, 0, 16 - $length).$i; |
|
| 150 | 150 | $i++; |
| 151 | 151 | } |
| 152 | 152 | } else { |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | $appName = $input->getArgument('app'); |
| 61 | 61 | $version = $input->getArgument('version'); |
| 62 | 62 | |
| 63 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
| 63 | + if (!preg_match('/^\d{1,16}$/', $version)) { |
|
| 64 | 64 | $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
| 65 | 65 | return 1; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml'; |
|
| 68 | + $schemaFile = $this->appManager->getAppPath($appName).'/appinfo/database.xml'; |
|
| 69 | 69 | if (!file_exists($schemaFile)) { |
| 70 | - $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>'); |
|
| 70 | + $output->writeln('<error>App '.$appName.' does not have a database.xml file</error>'); |
|
| 71 | 71 | return 2; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
| 81 | 81 | |
| 82 | 82 | $date = date('YmdHis'); |
| 83 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody); |
|
| 83 | + $path = $this->generateMigration($ms, 'Version'.$version.'Date'.$date, $schemaBody); |
|
| 84 | 84 | |
| 85 | 85 | $output->writeln("New migration class has been generated to <info>$path</info>"); |
| 86 | 86 | return 0; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $schemaManager = new \OC\DB\MDB2SchemaManager($toDB); |
| 235 | 235 | $apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps(); |
| 236 | - foreach($apps as $app) { |
|
| 236 | + foreach ($apps as $app) { |
|
| 237 | 237 | if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) { |
| 238 | 238 | $schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml'); |
| 239 | 239 | } else { |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | if (!empty($toTables)) { |
| 270 | 270 | $output->writeln('<info>Clearing schema in new database</info>'); |
| 271 | 271 | } |
| 272 | - foreach($toTables as $table) { |
|
| 272 | + foreach ($toTables as $table) { |
|
| 273 | 273 | $db->getSchemaManager()->dropTable($table); |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | protected function getTables(Connection $db) { |
| 278 | - $filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; |
|
| 278 | + $filterExpression = '/^'.preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')).'/'; |
|
| 279 | 279 | $db->getConfiguration()-> |
| 280 | 280 | setFilterSchemaAssetsExpression($filterExpression); |
| 281 | 281 | return $db->getSchemaManager()->listTableNames(); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @suppress SqlInjectionChecker |
| 291 | 291 | */ |
| 292 | 292 | protected function copyTable(Connection $fromDB, Connection $toDB, Table $table, InputInterface $input, OutputInterface $output) { |
| 293 | - if ($table->getName() === $toDB->getPrefix() . 'migrations') { |
|
| 293 | + if ($table->getName() === $toDB->getPrefix().'migrations') { |
|
| 294 | 294 | $output->writeln('<comment>Skipping migrations table because it was already filled by running the migrations</comment>'); |
| 295 | 295 | return; |
| 296 | 296 | } |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | $count = $result->fetchColumn(); |
| 306 | 306 | $result->closeCursor(); |
| 307 | 307 | |
| 308 | - $numChunks = ceil($count/$chunkSize); |
|
| 308 | + $numChunks = ceil($count / $chunkSize); |
|
| 309 | 309 | if ($numChunks > 1) { |
| 310 | - $output->writeln('chunked query, ' . $numChunks . ' chunks'); |
|
| 310 | + $output->writeln('chunked query, '.$numChunks.' chunks'); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $progress = new ProgressBar($output, $count); |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | try { |
| 396 | 396 | // copy table rows |
| 397 | - foreach($tables as $table) { |
|
| 397 | + foreach ($tables as $table) { |
|
| 398 | 398 | $output->writeln($table); |
| 399 | 399 | $this->copyTable($fromDB, $toDB, $schema->getTable($table), $input, $output); |
| 400 | 400 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | // save new database config |
| 406 | 406 | $this->saveDBInfo($input); |
| 407 | - } catch(\Exception $e) { |
|
| 407 | + } catch (\Exception $e) { |
|
| 408 | 408 | $this->config->setSystemValue('maintenance', false); |
| 409 | 409 | throw $e; |
| 410 | 410 | } |