Completed
Pull Request — master (#7879)
by Joas
37:17 queued 16:05
created
lib/private/legacy/app.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		$apps = self::getEnabledApps();
114 114
 
115 115
 		// Add each apps' folder as allowed class path
116
-		foreach($apps as $app) {
116
+		foreach ($apps as $app) {
117 117
 			$path = self::getAppPath($app);
118
-			if($path !== false) {
118
+			if ($path !== false) {
119 119
 				self::registerAutoloading($app, $path);
120 120
 			}
121 121
 		}
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 	public static function loadApp($app) {
141 141
 		self::$loadedApps[] = $app;
142 142
 		$appPath = self::getAppPath($app);
143
-		if($appPath === false) {
143
+		if ($appPath === false) {
144 144
 			return;
145 145
 		}
146 146
 
147 147
 		// in case someone calls loadApp() directly
148 148
 		self::registerAutoloading($app, $appPath);
149 149
 
150
-		if (is_file($appPath . '/appinfo/app.php')) {
151
-			\OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
150
+		if (is_file($appPath.'/appinfo/app.php')) {
151
+			\OC::$server->getEventLogger()->start('load_app_'.$app, 'Load app: '.$app);
152 152
 			self::requireAppFile($app);
153 153
 			if (self::isType($app, array('authentication'))) {
154 154
 				// since authentication apps affect the "is app enabled for group" check,
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				// enabled for groups
158 158
 				self::$enabledAppsCache = array();
159 159
 			}
160
-			\OC::$server->getEventLogger()->end('load_app_' . $app);
160
+			\OC::$server->getEventLogger()->end('load_app_'.$app);
161 161
 		}
162 162
 
163 163
 		$info = self::getAppInfo($app);
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			$plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ?
182 182
 				[$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin'];
183 183
 			foreach ($plugins as $plugin) {
184
-				if($plugin['@attributes']['type'] === 'collaborator-search') {
184
+				if ($plugin['@attributes']['type'] === 'collaborator-search') {
185 185
 					$pluginInfo = [
186 186
 						'shareType' => $plugin['@attributes']['share-type'],
187 187
 						'class' => $plugin['@value'],
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @param string $path
201 201
 	 */
202 202
 	public static function registerAutoloading($app, $path) {
203
-		$key = $app . '-' . $path;
204
-		if(isset(self::$alreadyRegistered[$key])) {
203
+		$key = $app.'-'.$path;
204
+		if (isset(self::$alreadyRegistered[$key])) {
205 205
 			return;
206 206
 		}
207 207
 
@@ -211,17 +211,17 @@  discard block
 block discarded – undo
211 211
 		$appNamespace = \OC\AppFramework\App::buildAppNamespace($app);
212 212
 		\OC::$server->registerNamespace($app, $appNamespace);
213 213
 
214
-		if (file_exists($path . '/composer/autoload.php')) {
215
-			require_once $path . '/composer/autoload.php';
214
+		if (file_exists($path.'/composer/autoload.php')) {
215
+			require_once $path.'/composer/autoload.php';
216 216
 		} else {
217
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true);
217
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true);
218 218
 			// Register on legacy autoloader
219 219
 			\OC::$loader->addValidRoot($path);
220 220
 		}
221 221
 
222 222
 		// Register Test namespace only when testing
223 223
 		if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) {
224
-			\OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true);
224
+			\OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true);
225 225
 		}
226 226
 	}
227 227
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	private static function requireAppFile($app) {
234 234
 		try {
235 235
 			// encapsulated here to avoid variable scope conflicts
236
-			require_once $app . '/appinfo/app.php';
236
+			require_once $app.'/appinfo/app.php';
237 237
 		} catch (Error $ex) {
238 238
 			\OC::$server->getLogger()->logException($ex);
239 239
 			if (!\OC::$server->getAppManager()->isShipped($app)) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 */
288 288
 	public static function setAppTypes($app) {
289 289
 		$appData = self::getAppInfo($app);
290
-		if(!is_array($appData)) {
290
+		if (!is_array($appData)) {
291 291
 			return;
292 292
 		}
293 293
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 		} else {
340 340
 			$apps = $appManager->getEnabledAppsForUser($user);
341 341
 		}
342
-		$apps = array_filter($apps, function ($app) {
343
-			return $app !== 'files';//we add this manually
342
+		$apps = array_filter($apps, function($app) {
343
+			return $app !== 'files'; //we add this manually
344 344
 		});
345 345
 		sort($apps);
346 346
 		array_unshift($apps, 'files');
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		$installer = \OC::$server->query(Installer::class);
379 379
 		$isDownloaded = $installer->isDownloaded($appId);
380 380
 
381
-		if(!$isDownloaded) {
381
+		if (!$isDownloaded) {
382 382
 			$installer->downloadApp($appId);
383 383
 		}
384 384
 
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 */
492 492
 	public static function findAppInDirectories($appId) {
493 493
 		$sanitizedAppId = self::cleanAppId($appId);
494
-		if($sanitizedAppId !== $appId) {
494
+		if ($sanitizedAppId !== $appId) {
495 495
 			return false;
496 496
 		}
497 497
 		static $app_dir = array();
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
 		$possibleApps = array();
504 504
 		foreach (OC::$APPSROOTS as $dir) {
505
-			if (file_exists($dir['path'] . '/' . $appId)) {
505
+			if (file_exists($dir['path'].'/'.$appId)) {
506 506
 				$possibleApps[] = $dir;
507 507
 			}
508 508
 		}
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		}
544 544
 
545 545
 		if (($dir = self::findAppInDirectories($appId)) != false) {
546
-			return $dir['path'] . '/' . $appId;
546
+			return $dir['path'].'/'.$appId;
547 547
 		}
548 548
 		return false;
549 549
 	}
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	 */
558 558
 	public static function getAppWebPath($appId) {
559 559
 		if (($dir = self::findAppInDirectories($appId)) != false) {
560
-			return OC::$WEBROOT . $dir['url'] . '/' . $appId;
560
+			return OC::$WEBROOT.$dir['url'].'/'.$appId;
561 561
 		}
562 562
 		return false;
563 563
 	}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 * @return string
571 571
 	 */
572 572
 	public static function getAppVersion($appId, $useCache = true) {
573
-		if($useCache && isset(self::$appVersion[$appId])) {
573
+		if ($useCache && isset(self::$appVersion[$appId])) {
574 574
 			return self::$appVersion[$appId];
575 575
 		}
576 576
 
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	 * @return string
587 587
 	 */
588 588
 	public static function getAppVersionByPath($path) {
589
-		$infoFile = $path . '/appinfo/info.xml';
589
+		$infoFile = $path.'/appinfo/info.xml';
590 590
 		$appData = self::getAppInfo($infoFile, true);
591 591
 		return isset($appData['version']) ? $appData['version'] : '';
592 592
 	}
@@ -609,10 +609,10 @@  discard block
 block discarded – undo
609 609
 				return self::$appInfo[$appId];
610 610
 			}
611 611
 			$appPath = self::getAppPath($appId);
612
-			if($appPath === false) {
612
+			if ($appPath === false) {
613 613
 				return null;
614 614
 			}
615
-			$file = $appPath . '/appinfo/info.xml';
615
+			$file = $appPath.'/appinfo/info.xml';
616 616
 		}
617 617
 
618 618
 		$parser = new InfoParser(\OC::$server->getMemCacheFactory()->createLocal('core.appinfo'));
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 		if (is_array($data)) {
622 622
 			$data = OC_App::parseAppInfo($data, $lang);
623 623
 		}
624
-		if(isset($data['ocsid'])) {
624
+		if (isset($data['ocsid'])) {
625 625
 			$storedId = \OC::$server->getConfig()->getAppValue($appId, 'ocsid');
626
-			if($storedId !== '' && $storedId !== $data['ocsid']) {
626
+			if ($storedId !== '' && $storedId !== $data['ocsid']) {
627 627
 				$data['ocsid'] = $storedId;
628 628
 			}
629 629
 		}
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 * @param string $page
716 716
 	 */
717 717
 	public static function registerAdmin($app, $page) {
718
-		self::$adminForms[] = $app . '/' . $page . '.php';
718
+		self::$adminForms[] = $app.'/'.$page.'.php';
719 719
 	}
720 720
 
721 721
 	/**
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 * @param string $page
725 725
 	 */
726 726
 	public static function registerPersonal($app, $page) {
727
-		self::$personalForms[] = $app . '/' . $page . '.php';
727
+		self::$personalForms[] = $app.'/'.$page.'.php';
728 728
 	}
729 729
 
730 730
 	/**
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 
754 754
 		foreach (OC::$APPSROOTS as $apps_dir) {
755 755
 			if (!is_readable($apps_dir['path'])) {
756
-				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
756
+				\OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], \OCP\Util::WARN);
757 757
 				continue;
758 758
 			}
759 759
 			$dh = opendir($apps_dir['path']);
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 			if (is_resource($dh)) {
762 762
 				while (($file = readdir($dh)) !== false) {
763 763
 
764
-					if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
764
+					if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) {
765 765
 
766 766
 						$apps[] = $file;
767 767
 					}
@@ -794,12 +794,12 @@  discard block
 block discarded – undo
794 794
 
795 795
 				$info = OC_App::getAppInfo($app, false, $langCode);
796 796
 				if (!is_array($info)) {
797
-					\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', \OCP\Util::ERROR);
797
+					\OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', \OCP\Util::ERROR);
798 798
 					continue;
799 799
 				}
800 800
 
801 801
 				if (!isset($info['name'])) {
802
-					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
802
+					\OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', \OCP\Util::ERROR);
803 803
 					continue;
804 804
 				}
805 805
 
@@ -826,13 +826,13 @@  discard block
 block discarded – undo
826 826
 				}
827 827
 
828 828
 				$appPath = self::getAppPath($app);
829
-				if($appPath !== false) {
830
-					$appIcon = $appPath . '/img/' . $app . '.svg';
829
+				if ($appPath !== false) {
830
+					$appIcon = $appPath.'/img/'.$app.'.svg';
831 831
 					if (file_exists($appIcon)) {
832
-						$info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
832
+						$info['preview'] = $urlGenerator->imagePath($app, $app.'.svg');
833 833
 						$info['previewAsIcon'] = true;
834 834
 					} else {
835
-						$appIcon = $appPath . '/img/app.svg';
835
+						$appIcon = $appPath.'/img/app.svg';
836 836
 						if (file_exists($appIcon)) {
837 837
 							$info['preview'] = $urlGenerator->imagePath($app, 'app.svg');
838 838
 							$info['previewAsIcon'] = true;
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 	public static function getAppVersions() {
958 958
 		static $versions;
959 959
 
960
-		if(!$versions) {
960
+		if (!$versions) {
961 961
 			$appConfig = \OC::$server->getAppConfig();
962 962
 			$versions = $appConfig->getValues(false, 'installed_version');
963 963
 		}
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 		if ($app !== false) {
980 980
 			// check if the app is compatible with this version of ownCloud
981 981
 			$info = self::getAppInfo($app);
982
-			if(!is_array($info)) {
982
+			if (!is_array($info)) {
983 983
 				throw new \Exception(
984 984
 					$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
985 985
 						[$info['name']]
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 				$config->setAppValue($app, 'ocsid', $appData['id']);
1005 1005
 			}
1006 1006
 
1007
-			if(isset($info['settings']) && is_array($info['settings'])) {
1007
+			if (isset($info['settings']) && is_array($info['settings'])) {
1008 1008
 				$appPath = self::getAppPath($app);
1009 1009
 				self::registerAutoloading($app, $appPath);
1010 1010
 				\OC::$server->getSettingsManager()->setupSettings($info['settings']);
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 
1013 1013
 			\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
1014 1014
 		} else {
1015
-			if(empty($appName) ) {
1015
+			if (empty($appName)) {
1016 1016
 				throw new \Exception($l->t("No app name specified"));
1017 1017
 			} else {
1018 1018
 				throw new \Exception($l->t("App '%s' could not be installed!", $appName));
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 	 */
1031 1031
 	public static function updateApp($appId) {
1032 1032
 		$appPath = self::getAppPath($appId);
1033
-		if($appPath === false) {
1033
+		if ($appPath === false) {
1034 1034
 			return false;
1035 1035
 		}
1036 1036
 		self::registerAutoloading($appId, $appPath);
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 		$appData = self::getAppInfo($appId);
1039 1039
 		self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
1040 1040
 
1041
-		if (file_exists($appPath . '/appinfo/database.xml')) {
1042
-			OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
1041
+		if (file_exists($appPath.'/appinfo/database.xml')) {
1042
+			OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml');
1043 1043
 		} else {
1044 1044
 			$ms = new MigrationService($appId, \OC::$server->getDatabaseConnection());
1045 1045
 			$ms->migrate();
@@ -1050,26 +1050,26 @@  discard block
 block discarded – undo
1050 1050
 		unset(self::$appVersion[$appId]);
1051 1051
 
1052 1052
 		// run upgrade code
1053
-		if (file_exists($appPath . '/appinfo/update.php')) {
1053
+		if (file_exists($appPath.'/appinfo/update.php')) {
1054 1054
 			self::loadApp($appId);
1055
-			include $appPath . '/appinfo/update.php';
1055
+			include $appPath.'/appinfo/update.php';
1056 1056
 		}
1057 1057
 		self::setupBackgroundJobs($appData['background-jobs']);
1058
-		if(isset($appData['settings']) && is_array($appData['settings'])) {
1058
+		if (isset($appData['settings']) && is_array($appData['settings'])) {
1059 1059
 			\OC::$server->getSettingsManager()->setupSettings($appData['settings']);
1060 1060
 		}
1061 1061
 
1062 1062
 		//set remote/public handlers
1063 1063
 		if (array_key_exists('ocsid', $appData)) {
1064 1064
 			\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
1065
-		} elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1065
+		} elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
1066 1066
 			\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
1067 1067
 		}
1068 1068
 		foreach ($appData['remote'] as $name => $path) {
1069
-			\OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
1069
+			\OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path);
1070 1070
 		}
1071 1071
 		foreach ($appData['public'] as $name => $path) {
1072
-			\OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path);
1072
+			\OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path);
1073 1073
 		}
1074 1074
 
1075 1075
 		self::setAppTypes($appId);
@@ -1139,17 +1139,17 @@  discard block
 block discarded – undo
1139 1139
 	public static function getStorage($appId) {
1140 1140
 		if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
1141 1141
 			if (\OC::$server->getUserSession()->isLoggedIn()) {
1142
-				$view = new \OC\Files\View('/' . OC_User::getUser());
1142
+				$view = new \OC\Files\View('/'.OC_User::getUser());
1143 1143
 				if (!$view->file_exists($appId)) {
1144 1144
 					$view->mkdir($appId);
1145 1145
 				}
1146
-				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
1146
+				return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId);
1147 1147
 			} else {
1148
-				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
1148
+				\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', \OCP\Util::ERROR);
1149 1149
 				return false;
1150 1150
 			}
1151 1151
 		} else {
1152
-			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
1152
+			\OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', \OCP\Util::ERROR);
1153 1153
 			return false;
1154 1154
 		}
1155 1155
 	}
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
 
1182 1182
 				if ($attributeLang === $similarLang) {
1183 1183
 					$similarLangFallback = $option['@value'];
1184
-				} else if (strpos($attributeLang, $similarLang . '_') === 0) {
1184
+				} else if (strpos($attributeLang, $similarLang.'_') === 0) {
1185 1185
 					if ($similarLangFallback === false) {
1186
-						$similarLangFallback =  $option['@value'];
1186
+						$similarLangFallback = $option['@value'];
1187 1187
 					}
1188 1188
 				}
1189 1189
 			} else {
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 			$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
1219 1219
 		} else if (isset($data['description']) && is_string($data['description'])) {
1220 1220
 			$data['description'] = trim($data['description']);
1221
-		} else  {
1221
+		} else {
1222 1222
 			$data['description'] = '';
1223 1223
 		}
1224 1224
 
Please login to merge, or discard this patch.