@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public static function initPaths(): void { |
83 | 83 | if (defined('PHPUNIT_CONFIG_DIR')) { |
84 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
85 | - } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
86 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
84 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
85 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
86 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
87 | 87 | } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
88 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
88 | + self::$configDir = rtrim($dir, '/').'/'; |
|
89 | 89 | } else { |
90 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
90 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
91 | 91 | } |
92 | 92 | self::$config = new \OC\Config(self::$configDir); |
93 | 93 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | //make sure suburi follows the same rules as scriptName |
117 | 117 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
118 | 118 | if (substr(OC::$SUBURI, -1) != '/') { |
119 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
119 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
120 | 120 | } |
121 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
121 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
130 | 130 | |
131 | 131 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
132 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
132 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
133 | 133 | } |
134 | 134 | } else { |
135 | 135 | // The scriptName is not ending with OC::$SUBURI |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | // slash which is required by URL generation. |
144 | 144 | if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT && |
145 | 145 | substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
146 | - header('Location: ' . \OC::$WEBROOT . '/'); |
|
146 | + header('Location: '.\OC::$WEBROOT.'/'); |
|
147 | 147 | exit(); |
148 | 148 | } |
149 | 149 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | OC::$APPSROOTS[] = $paths; |
159 | 159 | } |
160 | 160 | } |
161 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
162 | - OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
161 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
162 | + OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true]; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | if (empty(OC::$APPSROOTS)) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | public static function checkConfig(): void { |
185 | 185 | // Create config if it does not already exist |
186 | - $configFilePath = self::$configDir . '/config.php'; |
|
186 | + $configFilePath = self::$configDir.'/config.php'; |
|
187 | 187 | if (!file_exists($configFilePath)) { |
188 | 188 | @touch($configFilePath); |
189 | 189 | } |
@@ -197,18 +197,18 @@ discard block |
||
197 | 197 | $l = Server::get(\OCP\L10N\IFactory::class)->get('lib'); |
198 | 198 | |
199 | 199 | if (self::$CLI) { |
200 | - echo $l->t('Cannot write into "config" directory!') . "\n"; |
|
201 | - echo $l->t('This can usually be fixed by giving the web server write access to the config directory.') . "\n"; |
|
200 | + echo $l->t('Cannot write into "config" directory!')."\n"; |
|
201 | + echo $l->t('This can usually be fixed by giving the web server write access to the config directory.')."\n"; |
|
202 | 202 | echo "\n"; |
203 | - echo $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.') . "\n"; |
|
204 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ]) . "\n"; |
|
203 | + echo $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n"; |
|
204 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n"; |
|
205 | 205 | exit; |
206 | 206 | } else { |
207 | 207 | Server::get(ITemplateManager::class)->printErrorPage( |
208 | 208 | $l->t('Cannot write into "config" directory!'), |
209 | - $l->t('This can usually be fixed by giving the web server write access to the config directory.') . ' ' |
|
210 | - . $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.') . ' ' |
|
211 | - . $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ]), |
|
209 | + $l->t('This can usually be fixed by giving the web server write access to the config directory.').' ' |
|
210 | + . $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.').' ' |
|
211 | + . $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')]), |
|
212 | 212 | 503 |
213 | 213 | ); |
214 | 214 | } |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | if (OC::$CLI) { |
225 | 225 | throw new Exception('Not installed'); |
226 | 226 | } else { |
227 | - $url = OC::$WEBROOT . '/index.php'; |
|
228 | - header('Location: ' . $url); |
|
227 | + $url = OC::$WEBROOT.'/index.php'; |
|
228 | + header('Location: '.$url); |
|
229 | 229 | } |
230 | 230 | exit(); |
231 | 231 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | public static function checkMaintenanceMode(\OC\SystemConfig $systemConfig): void { |
235 | 235 | // Allow ajax update script to execute without being stopped |
236 | - if (((bool)$systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { |
|
236 | + if (((bool) $systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { |
|
237 | 237 | // send http status 503 |
238 | 238 | http_response_code(503); |
239 | 239 | header('X-Nextcloud-Maintenance-Mode: 1'); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $incompatibleDisabledApps = []; |
337 | 337 | foreach ($incompatibleApps as $appInfo) { |
338 | 338 | if ($appManager->isShipped($appInfo['id'])) { |
339 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
339 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
340 | 340 | } |
341 | 341 | if (!in_array($appInfo['id'], $incompatibleOverwrites)) { |
342 | 342 | $incompatibleDisabledApps[] = $appInfo; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | if (!empty($incompatibleShippedApps)) { |
347 | 347 | $l = Server::get(\OCP\L10N\IFactory::class)->get('core'); |
348 | 348 | $hint = $l->t('Application %1$s is not present or has a non-compatible version with this server. Please check the apps directory.', [implode(', ', $incompatibleShippedApps)]); |
349 | - throw new \OCP\HintException('Application ' . implode(', ', $incompatibleShippedApps) . ' is not present or has a non-compatible version with this server. Please check the apps directory.', $hint); |
|
349 | + throw new \OCP\HintException('Application '.implode(', ', $incompatibleShippedApps).' is not present or has a non-compatible version with this server. Please check the apps directory.', $hint); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | |
392 | 392 | // set the cookie path to the Nextcloud directory |
393 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
393 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
394 | 394 | ini_set('session.cookie_path', $cookie_path); |
395 | 395 | |
396 | 396 | // Let the session name be changed in the initSession Hook |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | // if session can't be started break with http 500 error |
416 | 416 | } catch (Exception $e) { |
417 | - Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base','exception' => $e]); |
|
417 | + Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base', 'exception' => $e]); |
|
418 | 418 | //show the user a detailed error page |
419 | 419 | Server::get(ITemplateManager::class)->printExceptionErrorPage($e, 500); |
420 | 420 | die(); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | // session timeout |
427 | 427 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
428 | 428 | if (isset($_COOKIE[session_name()])) { |
429 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
429 | + setcookie(session_name(), '', -1, self::$WEBROOT ?: '/'); |
|
430 | 430 | } |
431 | 431 | Server::get(IUserSession::class)->logout(); |
432 | 432 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | foreach ($policies as $policy) { |
498 | 498 | header( |
499 | 499 | sprintf( |
500 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
500 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
501 | 501 | $cookiePrefix, |
502 | 502 | $policy, |
503 | 503 | $cookieParams['path'], |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | self::handleAuthHeaders(); |
578 | 578 | |
579 | 579 | // prevent any XML processing from loading external entities |
580 | - libxml_set_external_entity_loader(static function () { |
|
580 | + libxml_set_external_entity_loader(static function() { |
|
581 | 581 | return null; |
582 | 582 | }); |
583 | 583 | |
@@ -595,14 +595,14 @@ discard block |
||
595 | 595 | self::$CLI = (php_sapi_name() == 'cli'); |
596 | 596 | |
597 | 597 | // Add default composer PSR-4 autoloader, ensure apcu to be disabled |
598 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
598 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
599 | 599 | self::$composerAutoloader->setApcuPrefix(null); |
600 | 600 | |
601 | 601 | |
602 | 602 | try { |
603 | 603 | self::initPaths(); |
604 | 604 | // setup 3rdparty autoloader |
605 | - $vendorAutoLoad = OC::$SERVERROOT . '/3rdparty/autoload.php'; |
|
605 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
606 | 606 | if (!file_exists($vendorAutoLoad)) { |
607 | 607 | throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
608 | 608 | } |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | ); |
630 | 630 | $profiler->start(); |
631 | 631 | } catch (\Throwable $e) { |
632 | - logger('core')->error('Failed to start profiler: ' . $e->getMessage(), ['app' => 'base']); |
|
632 | + logger('core')->error('Failed to start profiler: '.$e->getMessage(), ['app' => 'base']); |
|
633 | 633 | } |
634 | 634 | |
635 | - if (self::$CLI && in_array('--' . \OCP\Console\ReservedOptions::DEBUG_LOG, $_SERVER['argv'])) { |
|
635 | + if (self::$CLI && in_array('--'.\OCP\Console\ReservedOptions::DEBUG_LOG, $_SERVER['argv'])) { |
|
636 | 636 | \OC\Core\Listener\BeforeMessageLoggedEventListener::setup(); |
637 | 637 | } |
638 | 638 | |
@@ -713,11 +713,11 @@ discard block |
||
713 | 713 | // Convert l10n string into regular string for usage in database |
714 | 714 | $staticErrors = []; |
715 | 715 | foreach ($errors as $error) { |
716 | - echo $error['error'] . "\n"; |
|
717 | - echo $error['hint'] . "\n\n"; |
|
716 | + echo $error['error']."\n"; |
|
717 | + echo $error['hint']."\n\n"; |
|
718 | 718 | $staticErrors[] = [ |
719 | - 'error' => (string)$error['error'], |
|
720 | - 'hint' => (string)$error['hint'], |
|
719 | + 'error' => (string) $error['error'], |
|
720 | + 'hint' => (string) $error['hint'], |
|
721 | 721 | ]; |
722 | 722 | } |
723 | 723 | |
@@ -837,11 +837,11 @@ discard block |
||
837 | 837 | $eventLogger->log('init', 'OC::init', $loaderStart, microtime(true)); |
838 | 838 | $eventLogger->start('runtime', 'Runtime'); |
839 | 839 | $eventLogger->start('request', 'Full request after boot'); |
840 | - register_shutdown_function(function () use ($eventLogger) { |
|
840 | + register_shutdown_function(function() use ($eventLogger) { |
|
841 | 841 | $eventLogger->end('request'); |
842 | 842 | }); |
843 | 843 | |
844 | - register_shutdown_function(function () { |
|
844 | + register_shutdown_function(function() { |
|
845 | 845 | $memoryPeak = memory_get_peak_usage(); |
846 | 846 | $logLevel = match (true) { |
847 | 847 | $memoryPeak > 500_000_000 => ILogger::FATAL, |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | default => null, |
851 | 851 | }; |
852 | 852 | if ($logLevel !== null) { |
853 | - $message = 'Request used more than 300 MB of RAM: ' . Util::humanFileSize($memoryPeak); |
|
853 | + $message = 'Request used more than 300 MB of RAM: '.Util::humanFileSize($memoryPeak); |
|
854 | 854 | $logger = Server::get(LoggerInterface::class); |
855 | 855 | $logger->log($logLevel, $message, ['app' => 'core']); |
856 | 856 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | if ($systemConfig->getValue('installed', false) && !\OCP\Util::needUpgrade()) { |
866 | 866 | // NOTE: This will be replaced to use OCP |
867 | 867 | $userSession = Server::get(\OC\User\Session::class); |
868 | - $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
868 | + $userSession->listen('\OC\User', 'postLogin', function() use ($userSession) { |
|
869 | 869 | if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) { |
870 | 870 | // reset brute force delay for this IP address and username |
871 | 871 | $uid = $userSession->getUser()->getUID(); |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | private static function registerAppRestrictionsHooks(): void { |
918 | 918 | /** @var \OC\Group\Manager $groupManager */ |
919 | 919 | $groupManager = Server::get(\OCP\IGroupManager::class); |
920 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
920 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) { |
|
921 | 921 | $appManager = Server::get(\OCP\App\IAppManager::class); |
922 | 922 | $apps = $appManager->getEnabledAppsForGroup($group); |
923 | 923 | foreach ($apps as $appId) { |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | if (function_exists('opcache_reset')) { |
990 | 990 | opcache_reset(); |
991 | 991 | } |
992 | - if (!((bool)$systemConfig->getValue('maintenance', false))) { |
|
992 | + if (!((bool) $systemConfig->getValue('maintenance', false))) { |
|
993 | 993 | self::printUpgradePage($systemConfig); |
994 | 994 | exit(); |
995 | 995 | } |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | |
1005 | 1005 | // Load minimum set of apps |
1006 | 1006 | if (!\OCP\Util::needUpgrade() |
1007 | - && !((bool)$systemConfig->getValue('maintenance', false))) { |
|
1007 | + && !((bool) $systemConfig->getValue('maintenance', false))) { |
|
1008 | 1008 | // For logged-in users: Load everything |
1009 | 1009 | if (Server::get(IUserSession::class)->isLoggedIn()) { |
1010 | 1010 | $appManager->loadApps(); |
@@ -1066,10 +1066,10 @@ discard block |
||
1066 | 1066 | if ($requestPath === '') { |
1067 | 1067 | // Someone is logged in |
1068 | 1068 | if (Server::get(IUserSession::class)->isLoggedIn()) { |
1069 | - header('Location: ' . Server::get(IURLGenerator::class)->linkToDefaultPageUrl()); |
|
1069 | + header('Location: '.Server::get(IURLGenerator::class)->linkToDefaultPageUrl()); |
|
1070 | 1070 | } else { |
1071 | 1071 | // Not handled and not logged in |
1072 | - header('Location: ' . Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.login.showLoginForm')); |
|
1072 | + header('Location: '.Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.login.showLoginForm')); |
|
1073 | 1073 | } |
1074 | 1074 | return; |
1075 | 1075 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | try { |
1153 | 1153 | $appAPIService = Server::get(OCA\AppAPI\Service\AppAPIService::class); |
1154 | 1154 | return $appAPIService->validateExAppRequestToNC($request); |
1155 | - } catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) { |
|
1155 | + } catch (\Psr\Container\NotFoundExceptionInterface | \Psr\Container\ContainerExceptionInterface $e) { |
|
1156 | 1156 | return false; |
1157 | 1157 | } |
1158 | 1158 | } |