Passed
Push — master ( c2ec38...93e299 )
by Joas
16:01 queued 12s
created
lib/private/Setup/AbstractDatabase.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -38,118 +38,118 @@
 block discarded – undo
38 38
 
39 39
 abstract class AbstractDatabase {
40 40
 
41
-	/** @var IL10N */
42
-	protected $trans;
43
-	/** @var string */
44
-	protected $dbUser;
45
-	/** @var string */
46
-	protected $dbPassword;
47
-	/** @var string */
48
-	protected $dbName;
49
-	/** @var string */
50
-	protected $dbHost;
51
-	/** @var string */
52
-	protected $dbPort;
53
-	/** @var string */
54
-	protected $tablePrefix;
55
-	/** @var SystemConfig */
56
-	protected $config;
57
-	/** @var LoggerInterface */
58
-	protected $logger;
59
-	/** @var ISecureRandom */
60
-	protected $random;
41
+    /** @var IL10N */
42
+    protected $trans;
43
+    /** @var string */
44
+    protected $dbUser;
45
+    /** @var string */
46
+    protected $dbPassword;
47
+    /** @var string */
48
+    protected $dbName;
49
+    /** @var string */
50
+    protected $dbHost;
51
+    /** @var string */
52
+    protected $dbPort;
53
+    /** @var string */
54
+    protected $tablePrefix;
55
+    /** @var SystemConfig */
56
+    protected $config;
57
+    /** @var LoggerInterface */
58
+    protected $logger;
59
+    /** @var ISecureRandom */
60
+    protected $random;
61 61
 
62
-	public function __construct(IL10N $trans, SystemConfig $config, LoggerInterface $logger, ISecureRandom $random) {
63
-		$this->trans = $trans;
64
-		$this->config = $config;
65
-		$this->logger = $logger;
66
-		$this->random = $random;
67
-	}
62
+    public function __construct(IL10N $trans, SystemConfig $config, LoggerInterface $logger, ISecureRandom $random) {
63
+        $this->trans = $trans;
64
+        $this->config = $config;
65
+        $this->logger = $logger;
66
+        $this->random = $random;
67
+    }
68 68
 
69
-	public function validate($config) {
70
-		$errors = [];
71
-		if (empty($config['dbuser']) && empty($config['dbname'])) {
72
-			$errors[] = $this->trans->t("Enter the database username and name for %s", [$this->dbprettyname]);
73
-		} elseif (empty($config['dbuser'])) {
74
-			$errors[] = $this->trans->t("Enter the database username for %s", [$this->dbprettyname]);
75
-		} elseif (empty($config['dbname'])) {
76
-			$errors[] = $this->trans->t("Enter the database name for %s", [$this->dbprettyname]);
77
-		}
78
-		if (substr_count($config['dbname'], '.') >= 1) {
79
-			$errors[] = $this->trans->t("You cannot use dots in the database name %s", [$this->dbprettyname]);
80
-		}
81
-		return $errors;
82
-	}
69
+    public function validate($config) {
70
+        $errors = [];
71
+        if (empty($config['dbuser']) && empty($config['dbname'])) {
72
+            $errors[] = $this->trans->t("Enter the database username and name for %s", [$this->dbprettyname]);
73
+        } elseif (empty($config['dbuser'])) {
74
+            $errors[] = $this->trans->t("Enter the database username for %s", [$this->dbprettyname]);
75
+        } elseif (empty($config['dbname'])) {
76
+            $errors[] = $this->trans->t("Enter the database name for %s", [$this->dbprettyname]);
77
+        }
78
+        if (substr_count($config['dbname'], '.') >= 1) {
79
+            $errors[] = $this->trans->t("You cannot use dots in the database name %s", [$this->dbprettyname]);
80
+        }
81
+        return $errors;
82
+    }
83 83
 
84
-	public function initialize($config) {
85
-		$dbUser = $config['dbuser'];
86
-		$dbPass = $config['dbpass'];
87
-		$dbName = $config['dbname'];
88
-		$dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
89
-		$dbPort = !empty($config['dbport']) ? $config['dbport'] : '';
90
-		$dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
84
+    public function initialize($config) {
85
+        $dbUser = $config['dbuser'];
86
+        $dbPass = $config['dbpass'];
87
+        $dbName = $config['dbname'];
88
+        $dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
89
+        $dbPort = !empty($config['dbport']) ? $config['dbport'] : '';
90
+        $dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
91 91
 
92
-		$this->config->setValues([
93
-			'dbname' => $dbName,
94
-			'dbhost' => $dbHost,
95
-			'dbport' => $dbPort,
96
-			'dbtableprefix' => $dbTablePrefix,
97
-		]);
92
+        $this->config->setValues([
93
+            'dbname' => $dbName,
94
+            'dbhost' => $dbHost,
95
+            'dbport' => $dbPort,
96
+            'dbtableprefix' => $dbTablePrefix,
97
+        ]);
98 98
 
99
-		$this->dbUser = $dbUser;
100
-		$this->dbPassword = $dbPass;
101
-		$this->dbName = $dbName;
102
-		$this->dbHost = $dbHost;
103
-		$this->dbPort = $dbPort;
104
-		$this->tablePrefix = $dbTablePrefix;
105
-	}
99
+        $this->dbUser = $dbUser;
100
+        $this->dbPassword = $dbPass;
101
+        $this->dbName = $dbName;
102
+        $this->dbHost = $dbHost;
103
+        $this->dbPort = $dbPort;
104
+        $this->tablePrefix = $dbTablePrefix;
105
+    }
106 106
 
107
-	/**
108
-	 * @param array $configOverwrite
109
-	 * @return \OC\DB\Connection
110
-	 */
111
-	protected function connect(array $configOverwrite = []): Connection {
112
-		$connectionParams = [
113
-			'host' => $this->dbHost,
114
-			'user' => $this->dbUser,
115
-			'password' => $this->dbPassword,
116
-			'tablePrefix' => $this->tablePrefix,
117
-			'dbname' => $this->dbName
118
-		];
107
+    /**
108
+     * @param array $configOverwrite
109
+     * @return \OC\DB\Connection
110
+     */
111
+    protected function connect(array $configOverwrite = []): Connection {
112
+        $connectionParams = [
113
+            'host' => $this->dbHost,
114
+            'user' => $this->dbUser,
115
+            'password' => $this->dbPassword,
116
+            'tablePrefix' => $this->tablePrefix,
117
+            'dbname' => $this->dbName
118
+        ];
119 119
 
120
-		// adding port support through installer
121
-		if (!empty($this->dbPort)) {
122
-			if (ctype_digit($this->dbPort)) {
123
-				$connectionParams['port'] = $this->dbPort;
124
-			} else {
125
-				$connectionParams['unix_socket'] = $this->dbPort;
126
-			}
127
-		} elseif (strpos($this->dbHost, ':')) {
128
-			// Host variable may carry a port or socket.
129
-			[$host, $portOrSocket] = explode(':', $this->dbHost, 2);
130
-			if (ctype_digit($portOrSocket)) {
131
-				$connectionParams['port'] = $portOrSocket;
132
-			} else {
133
-				$connectionParams['unix_socket'] = $portOrSocket;
134
-			}
135
-			$connectionParams['host'] = $host;
136
-		}
120
+        // adding port support through installer
121
+        if (!empty($this->dbPort)) {
122
+            if (ctype_digit($this->dbPort)) {
123
+                $connectionParams['port'] = $this->dbPort;
124
+            } else {
125
+                $connectionParams['unix_socket'] = $this->dbPort;
126
+            }
127
+        } elseif (strpos($this->dbHost, ':')) {
128
+            // Host variable may carry a port or socket.
129
+            [$host, $portOrSocket] = explode(':', $this->dbHost, 2);
130
+            if (ctype_digit($portOrSocket)) {
131
+                $connectionParams['port'] = $portOrSocket;
132
+            } else {
133
+                $connectionParams['unix_socket'] = $portOrSocket;
134
+            }
135
+            $connectionParams['host'] = $host;
136
+        }
137 137
 
138
-		$connectionParams = array_merge($connectionParams, $configOverwrite);
139
-		$cf = new ConnectionFactory($this->config);
140
-		return $cf->getConnection($this->config->getValue('dbtype', 'sqlite'), $connectionParams);
141
-	}
138
+        $connectionParams = array_merge($connectionParams, $configOverwrite);
139
+        $cf = new ConnectionFactory($this->config);
140
+        return $cf->getConnection($this->config->getValue('dbtype', 'sqlite'), $connectionParams);
141
+    }
142 142
 
143
-	/**
144
-	 * @param string $username
145
-	 */
146
-	abstract public function setupDatabase($username);
143
+    /**
144
+     * @param string $username
145
+     */
146
+    abstract public function setupDatabase($username);
147 147
 
148
-	public function runMigrations() {
149
-		if (!is_dir(\OC::$SERVERROOT."/core/Migrations")) {
150
-			return;
151
-		}
152
-		$ms = new MigrationService('core', \OC::$server->get(Connection::class));
153
-		$ms->migrate('latest', true);
154
-	}
148
+    public function runMigrations() {
149
+        if (!is_dir(\OC::$SERVERROOT."/core/Migrations")) {
150
+            return;
151
+        }
152
+        $ms = new MigrationService('core', \OC::$server->get(Connection::class));
153
+        $ms->migrate('latest', true);
154
+    }
155 155
 }
Please login to merge, or discard this patch.
lib/private/Setup/OCI.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -30,81 +30,81 @@
 block discarded – undo
30 30
 namespace OC\Setup;
31 31
 
32 32
 class OCI extends AbstractDatabase {
33
-	public $dbprettyname = 'Oracle';
33
+    public $dbprettyname = 'Oracle';
34 34
 
35
-	protected $dbtablespace;
35
+    protected $dbtablespace;
36 36
 
37
-	public function initialize($config) {
38
-		parent::initialize($config);
39
-		if (array_key_exists('dbtablespace', $config)) {
40
-			$this->dbtablespace = $config['dbtablespace'];
41
-		} else {
42
-			$this->dbtablespace = 'USERS';
43
-		}
44
-		// allow empty hostname for oracle
45
-		$this->dbHost = $config['dbhost'];
37
+    public function initialize($config) {
38
+        parent::initialize($config);
39
+        if (array_key_exists('dbtablespace', $config)) {
40
+            $this->dbtablespace = $config['dbtablespace'];
41
+        } else {
42
+            $this->dbtablespace = 'USERS';
43
+        }
44
+        // allow empty hostname for oracle
45
+        $this->dbHost = $config['dbhost'];
46 46
 
47
-		$this->config->setValues([
48
-			'dbhost' => $this->dbHost,
49
-			'dbtablespace' => $this->dbtablespace,
50
-		]);
51
-	}
47
+        $this->config->setValues([
48
+            'dbhost' => $this->dbHost,
49
+            'dbtablespace' => $this->dbtablespace,
50
+        ]);
51
+    }
52 52
 
53
-	public function validate($config) {
54
-		$errors = [];
55
-		if (empty($config['dbuser']) && empty($config['dbname'])) {
56
-			$errors[] = $this->trans->t("Enter the database username and name for %s", [$this->dbprettyname]);
57
-		} elseif (empty($config['dbuser'])) {
58
-			$errors[] = $this->trans->t("Enter the database username for %s", [$this->dbprettyname]);
59
-		} elseif (empty($config['dbname'])) {
60
-			$errors[] = $this->trans->t("Enter the database name for %s", [$this->dbprettyname]);
61
-		}
62
-		return $errors;
63
-	}
53
+    public function validate($config) {
54
+        $errors = [];
55
+        if (empty($config['dbuser']) && empty($config['dbname'])) {
56
+            $errors[] = $this->trans->t("Enter the database username and name for %s", [$this->dbprettyname]);
57
+        } elseif (empty($config['dbuser'])) {
58
+            $errors[] = $this->trans->t("Enter the database username for %s", [$this->dbprettyname]);
59
+        } elseif (empty($config['dbname'])) {
60
+            $errors[] = $this->trans->t("Enter the database name for %s", [$this->dbprettyname]);
61
+        }
62
+        return $errors;
63
+    }
64 64
 
65
-	public function setupDatabase($username) {
66
-		try {
67
-			$this->connect();
68
-		} catch (\Exception $e) {
69
-			$errorMessage = $this->getLastError();
70
-			if ($errorMessage) {
71
-				throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
72
-					$errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
73
-					. ' ORACLE_SID=' . getenv('ORACLE_SID')
74
-					. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
75
-					. ' NLS_LANG=' . getenv('NLS_LANG')
76
-					. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable', 0, $e);
77
-			}
78
-			throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
79
-				'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
80
-				. ' ORACLE_SID=' . getenv('ORACLE_SID')
81
-				. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
82
-				. ' NLS_LANG=' . getenv('NLS_LANG')
83
-				. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable', 0, $e);
84
-		}
65
+    public function setupDatabase($username) {
66
+        try {
67
+            $this->connect();
68
+        } catch (\Exception $e) {
69
+            $errorMessage = $this->getLastError();
70
+            if ($errorMessage) {
71
+                throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
72
+                    $errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
73
+                    . ' ORACLE_SID=' . getenv('ORACLE_SID')
74
+                    . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
75
+                    . ' NLS_LANG=' . getenv('NLS_LANG')
76
+                    . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable', 0, $e);
77
+            }
78
+            throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
79
+                'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
80
+                . ' ORACLE_SID=' . getenv('ORACLE_SID')
81
+                . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
82
+                . ' NLS_LANG=' . getenv('NLS_LANG')
83
+                . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable', 0, $e);
84
+        }
85 85
 
86
-		$this->config->setValues([
87
-			'dbuser' => $this->dbUser,
88
-			'dbname' => $this->dbName,
89
-			'dbpassword' => $this->dbPassword,
90
-		]);
91
-	}
86
+        $this->config->setValues([
87
+            'dbuser' => $this->dbUser,
88
+            'dbname' => $this->dbName,
89
+            'dbpassword' => $this->dbPassword,
90
+        ]);
91
+    }
92 92
 
93
-	/**
94
-	 * @param resource $connection
95
-	 * @return string
96
-	 */
97
-	protected function getLastError($connection = null) {
98
-		if ($connection) {
99
-			$error = oci_error($connection);
100
-		} else {
101
-			$error = oci_error();
102
-		}
103
-		foreach (['message', 'code'] as $key) {
104
-			if (isset($error[$key])) {
105
-				return $error[$key];
106
-			}
107
-		}
108
-		return '';
109
-	}
93
+    /**
94
+     * @param resource $connection
95
+     * @return string
96
+     */
97
+    protected function getLastError($connection = null) {
98
+        if ($connection) {
99
+            $error = oci_error($connection);
100
+        } else {
101
+            $error = oci_error();
102
+        }
103
+        foreach (['message', 'code'] as $key) {
104
+            if (isset($error[$key])) {
105
+                return $error[$key];
106
+            }
107
+        }
108
+        return '';
109
+    }
110 110
 }
Please login to merge, or discard this patch.