Passed
Push — master ( 0becd8...beba18 )
by Morris
11:53 queued 10s
created
lib/private/Setup.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 			$configuredDatabases = $this->config->getValue('supportedDatabases',
169 169
 				['sqlite', 'mysql', 'pgsql']);
170 170
 		}
171
-		if(!is_array($configuredDatabases)) {
171
+		if (!is_array($configuredDatabases)) {
172 172
 			throw new Exception('Supported databases are not properly configured.');
173 173
 		}
174 174
 
175 175
 		$supportedDatabases = array();
176 176
 
177
-		foreach($configuredDatabases as $database) {
178
-			if(array_key_exists($database, $availableDatabases)) {
177
+		foreach ($configuredDatabases as $database) {
178
+			if (array_key_exists($database, $availableDatabases)) {
179 179
 				$working = false;
180 180
 				$type = $availableDatabases[$database]['type'];
181 181
 				$call = $availableDatabases[$database]['call'];
182 182
 
183 183
 				if ($type === 'function') {
184 184
 					$working = $this->is_callable($call);
185
-				} elseif($type === 'pdo') {
185
+				} elseif ($type === 'pdo') {
186 186
 					$working = in_array($call, $this->getAvailableDbDriversForPdo(), true);
187 187
 				}
188
-				if($working) {
188
+				if ($working) {
189 189
 					$supportedDatabases[$database] = $availableDatabases[$database]['name'];
190 190
 				}
191 191
 			}
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		// Create data directory to test whether the .htaccess works
212 212
 		// Notice that this is not necessarily the same data directory as the one
213 213
 		// that will effectively be used.
214
-		if(!file_exists($dataDir)) {
214
+		if (!file_exists($dataDir)) {
215 215
 			@mkdir($dataDir);
216 216
 		}
217 217
 		$htAccessWorking = true;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		if (\OC_Util::runningOnMac()) {
235 235
 			$errors[] = [
236 236
 				'error' => $this->l10n->t(
237
-					'Mac OS X is not supported and %s will not work properly on this platform. ' .
237
+					'Mac OS X is not supported and %s will not work properly on this platform. '.
238 238
 					'Use it at your own risk! ',
239 239
 					[$this->defaults->getName()]
240 240
 				),
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 			];
243 243
 		}
244 244
 
245
-		if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
245
+		if ($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
246 246
 			$errors[] = [
247 247
 				'error' => $this->l10n->t(
248
-					'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. ' .
248
+					'It seems that this %s instance is running on a 32-bit PHP environment and the open_basedir has been configured in php.ini. '.
249 249
 					'This will lead to problems with files over 4 GB and is highly discouraged.',
250 250
 					[$this->defaults->getName()]
251 251
 				),
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
 		$error = array();
276 276
 		$dbType = $options['dbtype'];
277 277
 
278
-		if(empty($options['adminlogin'])) {
278
+		if (empty($options['adminlogin'])) {
279 279
 			$error[] = $l->t('Set an admin username.');
280 280
 		}
281
-		if(empty($options['adminpass'])) {
281
+		if (empty($options['adminpass'])) {
282 282
 			$error[] = $l->t('Set an admin password.');
283 283
 		}
284
-		if(empty($options['directory'])) {
284
+		if (empty($options['directory'])) {
285 285
 			$options['directory'] = \OC::$SERVERROOT."/data";
286 286
 		}
287 287
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		$request = \OC::$server->getRequest();
311 311
 
312 312
 		//no errors, good
313
-		if(isset($options['trusted_domains'])
313
+		if (isset($options['trusted_domains'])
314 314
 		    && is_array($options['trusted_domains'])) {
315 315
 			$trustedDomains = $options['trusted_domains'];
316 316
 		} else {
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 		];
339 339
 
340 340
 		if ($this->config->getValue('overwrite.cli.url', null) === null) {
341
-			$newConfigValues['overwrite.cli.url'] = $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT;
341
+			$newConfigValues['overwrite.cli.url'] = $request->getServerProtocol().'://'.$request->getInsecureServerHost().\OC::$WEBROOT;
342 342
 		}
343 343
 
344 344
 		$this->config->setValues($newConfigValues);
@@ -356,20 +356,20 @@  discard block
 block discarded – undo
356 356
 			return $error;
357 357
 		} catch (Exception $e) {
358 358
 			$error[] = [
359
-				'error' => 'Error while trying to create admin user: ' . $e->getMessage(),
359
+				'error' => 'Error while trying to create admin user: '.$e->getMessage(),
360 360
 				'hint' => '',
361 361
 			];
362 362
 			return $error;
363 363
 		}
364 364
 
365 365
 		//create the user and group
366
-		$user =  null;
366
+		$user = null;
367 367
 		try {
368 368
 			$user = \OC::$server->getUserManager()->createUser($username, $password);
369 369
 			if (!$user) {
370 370
 				$error[] = "User <$username> could not be created.";
371 371
 			}
372
-		} catch(Exception $exception) {
372
+		} catch (Exception $exception) {
373 373
 			$error[] = $exception->getMessage();
374 374
 		}
375 375
 
@@ -379,14 +379,14 @@  discard block
 block discarded – undo
379 379
 			$config->setAppValue('core', 'lastupdatedat', microtime(true));
380 380
 			$config->setAppValue('core', 'vendor', $this->getVendor());
381 381
 
382
-			$group =\OC::$server->getGroupManager()->createGroup('admin');
382
+			$group = \OC::$server->getGroupManager()->createGroup('admin');
383 383
 			$group->addUser($user);
384 384
 
385 385
 			// Install shipped apps and specified app bundles
386 386
 			Installer::installShippedApps();
387 387
 			$bundleFetcher = new BundleFetcher(\OC::$server->getL10N('lib'));
388 388
 			$defaultInstallationBundles = $bundleFetcher->getDefaultInstallationBundle();
389
-			foreach($defaultInstallationBundles as $bundle) {
389
+			foreach ($defaultInstallationBundles as $bundle) {
390 390
 				try {
391 391
 					$this->installer->installAppBundle($bundle);
392 392
 				} catch (Exception $e) {}
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
 		$htaccessContent = explode($content, $htaccessContent, 2)[0];
493 493
 
494 494
 		//custom 403 error page
495
-		$content .= "\nErrorDocument 403 " . $webRoot . '/';
495
+		$content .= "\nErrorDocument 403 ".$webRoot.'/';
496 496
 
497 497
 		//custom 404 error page
498
-		$content .= "\nErrorDocument 404 " . $webRoot . '/';
498
+		$content .= "\nErrorDocument 404 ".$webRoot.'/';
499 499
 
500 500
 		// Add rewrite rules if the RewriteBase is configured
501 501
 		$rewriteBase = $config->getValue('htaccess.RewriteBase', '');
502
-		if($rewriteBase !== '') {
502
+		if ($rewriteBase !== '') {
503 503
 			$content .= "\n<IfModule mod_rewrite.c>";
504 504
 			$content .= "\n  Options -MultiViews";
505 505
 			$content .= "\n  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]";
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			$content .= "\n  RewriteCond %{REQUEST_FILENAME} !/ocm-provider/";
521 521
 			$content .= "\n  RewriteCond %{REQUEST_URI} !^/\\.well-known/(acme-challenge|pki-validation)/.*";
522 522
 			$content .= "\n  RewriteRule . index.php [PT,E=PATH_INFO:$1]";
523
-			$content .= "\n  RewriteBase " . $rewriteBase;
523
+			$content .= "\n  RewriteBase ".$rewriteBase;
524 524
 			$content .= "\n  <IfModule mod_env.c>";
525 525
 			$content .= "\n    SetEnv front_controller_active true";
526 526
 			$content .= "\n    <IfModule mod_dir.c>";
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 
533 533
 		if ($content !== '') {
534 534
 			//suppress errors in case we don't have permissions for it
535
-			return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content . "\n");
535
+			return (bool) @file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent.$content."\n");
536 536
 		}
537 537
 
538 538
 		return false;
@@ -540,25 +540,25 @@  discard block
 block discarded – undo
540 540
 
541 541
 	public static function protectDataDirectory() {
542 542
 		//Require all denied
543
-		$now =  date('Y-m-d H:i:s');
543
+		$now = date('Y-m-d H:i:s');
544 544
 		$content = "# Generated by Nextcloud on $now\n";
545
-		$content.= "# line below if for Apache 2.4\n";
546
-		$content.= "<ifModule mod_authz_core.c>\n";
547
-		$content.= "Require all denied\n";
548
-		$content.= "</ifModule>\n\n";
549
-		$content.= "# line below if for Apache 2.2\n";
550
-		$content.= "<ifModule !mod_authz_core.c>\n";
551
-		$content.= "deny from all\n";
552
-		$content.= "Satisfy All\n";
553
-		$content.= "</ifModule>\n\n";
554
-		$content.= "# section for Apache 2.2 and 2.4\n";
555
-		$content.= "<ifModule mod_autoindex.c>\n";
556
-		$content.= "IndexIgnore *\n";
557
-		$content.= "</ifModule>\n";
558
-
559
-		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
560
-		file_put_contents($baseDir . '/.htaccess', $content);
561
-		file_put_contents($baseDir . '/index.html', '');
545
+		$content .= "# line below if for Apache 2.4\n";
546
+		$content .= "<ifModule mod_authz_core.c>\n";
547
+		$content .= "Require all denied\n";
548
+		$content .= "</ifModule>\n\n";
549
+		$content .= "# line below if for Apache 2.2\n";
550
+		$content .= "<ifModule !mod_authz_core.c>\n";
551
+		$content .= "deny from all\n";
552
+		$content .= "Satisfy All\n";
553
+		$content .= "</ifModule>\n\n";
554
+		$content .= "# section for Apache 2.2 and 2.4\n";
555
+		$content .= "<ifModule mod_autoindex.c>\n";
556
+		$content .= "IndexIgnore *\n";
557
+		$content .= "</ifModule>\n";
558
+
559
+		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
560
+		file_put_contents($baseDir.'/.htaccess', $content);
561
+		file_put_contents($baseDir.'/index.html', '');
562 562
 	}
563 563
 
564 564
 	/**
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 */
571 571
 	private function getVendor() {
572 572
 		// this should really be a JSON file
573
-		require \OC::$SERVERROOT . '/version.php';
573
+		require \OC::$SERVERROOT.'/version.php';
574 574
 		/** @var string $vendor */
575 575
 		return (string) $vendor;
576 576
 	}
Please login to merge, or discard this patch.