Passed
Push — master ( 309668...b1cb2e )
by John
15:52 queued 12s
created
lib/private/legacy/OC_Util.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		/** @var LoggerInterface $logger */
184 184
 		$logger = \OC::$server->get(LoggerInterface::class);
185 185
 
186
-		$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
186
+		$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT.'/core/skeleton');
187 187
 		$userLang = \OC::$server->getL10NFactory()->findLanguage();
188 188
 		$skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory);
189 189
 
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 		if ($instanceId === null) {
206 206
 			throw new \RuntimeException('no instance id!');
207 207
 		}
208
-		$appdata = 'appdata_' . $instanceId;
208
+		$appdata = 'appdata_'.$instanceId;
209 209
 		if ($userId === $appdata) {
210
-			throw new \RuntimeException('username is reserved name: ' . $appdata);
210
+			throw new \RuntimeException('username is reserved name: '.$appdata);
211 211
 		}
212 212
 
213 213
 		if (!empty($skeletonDirectory)) {
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 		// Copy the files
243 243
 		while (false !== ($file = readdir($dir))) {
244 244
 			if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
245
-				if (is_dir($source . '/' . $file)) {
245
+				if (is_dir($source.'/'.$file)) {
246 246
 					$child = $target->newFolder($file);
247
-					self::copyr($source . '/' . $file, $child);
247
+					self::copyr($source.'/'.$file, $child);
248 248
 				} else {
249 249
 					$child = $target->newFile($file);
250
-					$sourceStream = fopen($source . '/' . $file, 'r');
250
+					$sourceStream = fopen($source.'/'.$file, 'r');
251 251
 					if ($sourceStream === false) {
252
-						$logger->error(sprintf('Could not fopen "%s"', $source . '/' . $file), ['app' => 'core']);
252
+						$logger->error(sprintf('Could not fopen "%s"', $source.'/'.$file), ['app' => 'core']);
253 253
 						closedir($dir);
254 254
 						return;
255 255
 					}
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 			return;
326 326
 		}
327 327
 
328
-		$timestamp = filemtime(OC::$SERVERROOT . '/version.php');
329
-		require OC::$SERVERROOT . '/version.php';
328
+		$timestamp = filemtime(OC::$SERVERROOT.'/version.php');
329
+		require OC::$SERVERROOT.'/version.php';
330 330
 		/** @var int $timestamp */
331 331
 		self::$versionCache['OC_Version_Timestamp'] = $timestamp;
332 332
 		/** @var string $OC_Version */
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	public static function checkServer(\OC\SystemConfig $config) {
501 501
 		$l = \OC::$server->getL10N('lib');
502 502
 		$errors = [];
503
-		$CONFIG_DATADIRECTORY = $config->getValue('datadirectory', OC::$SERVERROOT . '/data');
503
+		$CONFIG_DATADIRECTORY = $config->getValue('datadirectory', OC::$SERVERROOT.'/data');
504 504
 
505 505
 		if (!self::needUpgrade($config) && $config->getValue('installed', false)) {
506 506
 			// this check needs to be done every time
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
 				$errors[] = [
541 541
 					'error' => $l->t('Cannot write into "config" directory.'),
542 542
 					'hint' => $l->t('This can usually be fixed by giving the web server write access to the config directory. See %s',
543
-						[ $urlGenerator->linkToDocs('admin-dir_permissions') ]) . '. '
543
+						[$urlGenerator->linkToDocs('admin-dir_permissions')]).'. '
544 544
 						. $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s',
545
-						[ $urlGenerator->linkToDocs('admin-config') ])
545
+						[$urlGenerator->linkToDocs('admin-config')])
546 546
 				];
547 547
 			}
548 548
 		}
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 			$version -= ($minor * 100);
717 717
 			$patch = $version;
718 718
 			$errors[] = [
719
-				'error' => $l->t('libxml2 2.7.0 is at least required. Currently %s is installed.', [$major . '.' . $minor . '.' . $patch]),
719
+				'error' => $l->t('libxml2 2.7.0 is at least required. Currently %s is installed.', [$major.'.'.$minor.'.'.$patch]),
720 720
 				'hint' => $l->t('To fix this issue update your libxml2 version and restart your web server.')
721 721
 			];
722 722
 		}
@@ -819,10 +819,10 @@  discard block
 block discarded – undo
819 819
 				'hint' => $l->t('Check the value of "datadirectory" in your configuration.')
820 820
 			];
821 821
 		}
822
-		if (!file_exists($dataDirectory . '/.ocdata')) {
822
+		if (!file_exists($dataDirectory.'/.ocdata')) {
823 823
 			$errors[] = [
824 824
 				'error' => $l->t('Your data directory is invalid.'),
825
-				'hint' => $l->t('Ensure there is a file called ".ocdata"' .
825
+				'hint' => $l->t('Ensure there is a file called ".ocdata"'.
826 826
 					' in the root of the data directory.')
827 827
 			];
828 828
 		}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	public static function checkLoggedIn() {
839 839
 		// Check if we are a user
840 840
 		if (!\OC::$server->getUserSession()->isLoggedIn()) {
841
-			header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute(
841
+			header('Location: '.\OC::$server->getURLGenerator()->linkToRoute(
842 842
 						'core.login.showLoginForm',
843 843
 						[
844 844
 							'redirect_url' => \OC::$server->getRequest()->getRequestUri(),
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 		}
850 850
 		// Redirect to 2FA challenge selection if 2FA challenge was not solved yet
851 851
 		if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
852
-			header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge'));
852
+			header('Location: '.\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge'));
853 853
 			exit();
854 854
 		}
855 855
 	}
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	public static function checkAdminUser() {
863 863
 		OC_Util::checkLoggedIn();
864 864
 		if (!OC_User::isAdminUser(OC_User::getUser())) {
865
-			header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php'));
865
+			header('Location: '.\OCP\Util::linkToAbsolute('', 'index.php'));
866 866
 			exit();
867 867
 		}
868 868
 	}
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 	 */
889 889
 	public static function redirectToDefaultPage() {
890 890
 		$location = self::getDefaultPageUrl();
891
-		header('Location: ' . $location);
891
+		header('Location: '.$location);
892 892
 		exit();
893 893
 	}
894 894
 
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 		$id = \OC::$server->getSystemConfig()->getValue('instanceid', null);
902 902
 		if (is_null($id)) {
903 903
 			// We need to guarantee at least one letter in instanceid so it can be used as the session_name
904
-			$id = 'oc' . \OC::$server->getSecureRandom()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
904
+			$id = 'oc'.\OC::$server->getSecureRandom()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
905 905
 			\OC::$server->getSystemConfig()->setValue('instanceid', $id);
906 906
 		}
907 907
 		return $id;
@@ -919,12 +919,12 @@  discard block
 block discarded – undo
919 919
 	public static function sanitizeHTML($value) {
920 920
 		if (is_array($value)) {
921 921
 			/** @var string[] $value */
922
-			$value = array_map(function ($value) {
922
+			$value = array_map(function($value) {
923 923
 				return self::sanitizeHTML($value);
924 924
 			}, $value);
925 925
 		} else {
926 926
 			// Specify encoding for PHP<5.4
927
-			$value = htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
927
+			$value = htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
928 928
 		}
929 929
 		return $value;
930 930
 	}
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 		$testContent = 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.';
958 958
 
959 959
 		// creating a test file
960
-		$testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
960
+		$testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT.'/data').'/'.$fileName;
961 961
 
962 962
 		if (file_exists($testFile)) {// already running this test, possible recursive call
963 963
 			return false;
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 		$fp = @fopen($testFile, 'w');
967 967
 		if (!$fp) {
968 968
 			throw new \OCP\HintException('Can\'t create test file to check for working .htaccess file.',
969
-				'Make sure it is possible for the web server to write to ' . $testFile);
969
+				'Make sure it is possible for the web server to write to '.$testFile);
970 970
 		}
971 971
 		fwrite($fp, $testContent);
972 972
 		fclose($fp);
@@ -993,10 +993,10 @@  discard block
 block discarded – undo
993 993
 		}
994 994
 
995 995
 		$fileName = '/htaccesstest.txt';
996
-		$testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
996
+		$testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT.'/data').'/'.$fileName;
997 997
 
998 998
 		// accessing the file via http
999
-		$url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName);
999
+		$url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT.'/data'.$fileName);
1000 1000
 		try {
1001 1001
 			$content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody();
1002 1002
 		} catch (\Exception $e) {
@@ -1004,9 +1004,9 @@  discard block
 block discarded – undo
1004 1004
 		}
1005 1005
 
1006 1006
 		if (strpos($url, 'https:') === 0) {
1007
-			$url = 'http:' . substr($url, 6);
1007
+			$url = 'http:'.substr($url, 6);
1008 1008
 		} else {
1009
-			$url = 'https:' . substr($url, 5);
1009
+			$url = 'https:'.substr($url, 5);
1010 1010
 		}
1011 1011
 
1012 1012
 		try {
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 		$theme = \OC::$server->getSystemConfig()->getValue("theme", '');
1113 1113
 
1114 1114
 		if ($theme === '') {
1115
-			if (is_dir(OC::$SERVERROOT . '/themes/default')) {
1115
+			if (is_dir(OC::$SERVERROOT.'/themes/default')) {
1116 1116
 				$theme = 'default';
1117 1117
 			}
1118 1118
 		}
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
 		$normalizedValue = Normalizer::normalize($value);
1135 1135
 		if ($normalizedValue === null || $normalizedValue === false) {
1136
-			\OC::$server->getLogger()->warning('normalizing failed for "' . $value . '"', ['app' => 'core']);
1136
+			\OC::$server->getLogger()->warning('normalizing failed for "'.$value.'"', ['app' => 'core']);
1137 1137
 			return $value;
1138 1138
 		}
1139 1139
 
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 		$version = OC_Util::getVersionString();
1150 1150
 		$build = OC_Util::getBuild();
1151 1151
 		if (!empty($build) and OC_Util::getChannel() === 'daily') {
1152
-			$version .= ' Build:' . $build;
1152
+			$version .= ' Build:'.$build;
1153 1153
 		}
1154 1154
 		return $version;
1155 1155
 	}
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 		}
1172 1172
 
1173 1173
 		// detect part files
1174
-		if (preg_match('/' . \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX . '/', $trimmed) !== 0) {
1174
+		if (preg_match('/'.\OCP\Files\FileInfo::BLACKLIST_FILES_REGEX.'/', $trimmed) !== 0) {
1175 1175
 			return false;
1176 1176
 		}
1177 1177
 
@@ -1202,19 +1202,19 @@  discard block
 block discarded – undo
1202 1202
 			} elseif ($config->getValue('debug', false) && $versionDiff < 0) {
1203 1203
 				// downgrade with debug
1204 1204
 				$installedMajor = explode('.', $installedVersion);
1205
-				$installedMajor = $installedMajor[0] . '.' . $installedMajor[1];
1205
+				$installedMajor = $installedMajor[0].'.'.$installedMajor[1];
1206 1206
 				$currentMajor = explode('.', $currentVersion);
1207
-				$currentMajor = $currentMajor[0] . '.' . $currentMajor[1];
1207
+				$currentMajor = $currentMajor[0].'.'.$currentMajor[1];
1208 1208
 				if ($installedMajor === $currentMajor) {
1209 1209
 					// Same major, allow downgrade for developers
1210 1210
 					return true;
1211 1211
 				} else {
1212 1212
 					// downgrade attempt, throw exception
1213
-					throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
1213
+					throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from '.$installedVersion.' to '.$currentVersion.')');
1214 1214
 				}
1215 1215
 			} elseif ($versionDiff < 0) {
1216 1216
 				// downgrade attempt, throw exception
1217
-				throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
1217
+				throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from '.$installedVersion.' to '.$currentVersion.')');
1218 1218
 			}
1219 1219
 
1220 1220
 			// also check for upgrades for apps (independently from the user)
Please login to merge, or discard this patch.