@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public static function initPaths(): void { |
| 84 | 84 | if (defined('PHPUNIT_CONFIG_DIR')) { |
| 85 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
| 86 | - } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
| 87 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
| 85 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
| 86 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
| 87 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
| 88 | 88 | } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
| 89 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
| 89 | + self::$configDir = rtrim($dir, '/').'/'; |
|
| 90 | 90 | } else { |
| 91 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
| 91 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
| 92 | 92 | } |
| 93 | 93 | self::$config = new \OC\Config(self::$configDir); |
| 94 | 94 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | //make sure suburi follows the same rules as scriptName |
| 118 | 118 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
| 119 | 119 | if (substr(OC::$SUBURI, -1) != '/') { |
| 120 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
| 120 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
| 121 | 121 | } |
| 122 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
| 122 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
| 131 | 131 | |
| 132 | 132 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
| 133 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
| 133 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
| 134 | 134 | } |
| 135 | 135 | } else { |
| 136 | 136 | // The scriptName is not ending with OC::$SUBURI |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | // slash which is required by URL generation. |
| 145 | 145 | if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT |
| 146 | 146 | && substr($_SERVER['REQUEST_URI'], -1) !== '/') { |
| 147 | - header('Location: ' . \OC::$WEBROOT . '/'); |
|
| 147 | + header('Location: '.\OC::$WEBROOT.'/'); |
|
| 148 | 148 | exit(); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | OC::$APPSROOTS[] = $paths; |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
| 163 | - OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
| 162 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
| 163 | + OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true]; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | if (empty(OC::$APPSROOTS)) { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | public static function checkConfig(): void { |
| 186 | 186 | // Create config if it does not already exist |
| 187 | - $configFilePath = self::$configDir . '/config.php'; |
|
| 187 | + $configFilePath = self::$configDir.'/config.php'; |
|
| 188 | 188 | if (!file_exists($configFilePath)) { |
| 189 | 189 | @touch($configFilePath); |
| 190 | 190 | } |
@@ -198,18 +198,18 @@ discard block |
||
| 198 | 198 | $l = Server::get(\OCP\L10N\IFactory::class)->get('lib'); |
| 199 | 199 | |
| 200 | 200 | if (self::$CLI) { |
| 201 | - echo $l->t('Cannot write into "config" directory!') . "\n"; |
|
| 202 | - echo $l->t('This can usually be fixed by giving the web server write access to the config directory.') . "\n"; |
|
| 201 | + echo $l->t('Cannot write into "config" directory!')."\n"; |
|
| 202 | + echo $l->t('This can usually be fixed by giving the web server write access to the config directory.')."\n"; |
|
| 203 | 203 | echo "\n"; |
| 204 | - 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"; |
|
| 205 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ]) . "\n"; |
|
| 204 | + 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"; |
|
| 205 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n"; |
|
| 206 | 206 | exit; |
| 207 | 207 | } else { |
| 208 | 208 | Server::get(ITemplateManager::class)->printErrorPage( |
| 209 | 209 | $l->t('Cannot write into "config" directory!'), |
| 210 | - $l->t('This can usually be fixed by giving the web server write access to the config directory.') . ' ' |
|
| 211 | - . $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.') . ' ' |
|
| 212 | - . $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ]), |
|
| 210 | + $l->t('This can usually be fixed by giving the web server write access to the config directory.').' ' |
|
| 211 | + . $l->t('But, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.').' ' |
|
| 212 | + . $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')]), |
|
| 213 | 213 | 503 |
| 214 | 214 | ); |
| 215 | 215 | } |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | if (OC::$CLI) { |
| 226 | 226 | throw new Exception('Not installed'); |
| 227 | 227 | } else { |
| 228 | - $url = OC::$WEBROOT . '/index.php'; |
|
| 229 | - header('Location: ' . $url); |
|
| 228 | + $url = OC::$WEBROOT.'/index.php'; |
|
| 229 | + header('Location: '.$url); |
|
| 230 | 230 | } |
| 231 | 231 | exit(); |
| 232 | 232 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | public static function checkMaintenanceMode(\OC\SystemConfig $systemConfig): void { |
| 236 | 236 | // Allow ajax update script to execute without being stopped |
| 237 | - if (((bool)$systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { |
|
| 237 | + if (((bool) $systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { |
|
| 238 | 238 | // send http status 503 |
| 239 | 239 | http_response_code(503); |
| 240 | 240 | header('X-Nextcloud-Maintenance-Mode: 1'); |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $incompatibleDisabledApps = []; |
| 339 | 339 | foreach ($incompatibleApps as $appInfo) { |
| 340 | 340 | if ($appManager->isShipped($appInfo['id'])) { |
| 341 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
| 341 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
| 342 | 342 | } |
| 343 | 343 | if (!in_array($appInfo['id'], $incompatibleOverwrites)) { |
| 344 | 344 | $incompatibleDisabledApps[] = $appInfo; |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | if (!empty($incompatibleShippedApps)) { |
| 349 | 349 | $l = Server::get(\OCP\L10N\IFactory::class)->get('core'); |
| 350 | 350 | $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)]); |
| 351 | - 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); |
|
| 351 | + 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); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | ini_set('session.cookie_httponly', 'true'); |
| 386 | 386 | |
| 387 | 387 | // set the cookie path to the Nextcloud directory |
| 388 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
| 388 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
| 389 | 389 | ini_set('session.cookie_path', $cookie_path); |
| 390 | 390 | |
| 391 | 391 | // set the cookie domain to the Nextcloud domain |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | // if session can't be started break with http 500 error |
| 425 | 425 | } catch (Exception $e) { |
| 426 | - Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base','exception' => $e]); |
|
| 426 | + Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'base', 'exception' => $e]); |
|
| 427 | 427 | //show the user a detailed error page |
| 428 | 428 | Server::get(ITemplateManager::class)->printExceptionErrorPage($e, 500); |
| 429 | 429 | die(); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | // session timeout |
| 436 | 436 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
| 437 | 437 | if (isset($_COOKIE[session_name()])) { |
| 438 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
| 438 | + setcookie(session_name(), '', -1, self::$WEBROOT ?: '/'); |
|
| 439 | 439 | } |
| 440 | 440 | Server::get(IUserSession::class)->logout(); |
| 441 | 441 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | foreach ($policies as $policy) { |
| 507 | 507 | header( |
| 508 | 508 | sprintf( |
| 509 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 509 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 510 | 510 | $cookiePrefix, |
| 511 | 511 | $policy, |
| 512 | 512 | $cookieParams['path'], |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | self::handleAuthHeaders(); |
| 587 | 587 | |
| 588 | 588 | // prevent any XML processing from loading external entities |
| 589 | - libxml_set_external_entity_loader(static function () { |
|
| 589 | + libxml_set_external_entity_loader(static function() { |
|
| 590 | 590 | return null; |
| 591 | 591 | }); |
| 592 | 592 | |
@@ -604,14 +604,14 @@ discard block |
||
| 604 | 604 | self::$CLI = (php_sapi_name() == 'cli'); |
| 605 | 605 | |
| 606 | 606 | // Add default composer PSR-4 autoloader, ensure apcu to be disabled |
| 607 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
| 607 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
| 608 | 608 | self::$composerAutoloader->setApcuPrefix(null); |
| 609 | 609 | |
| 610 | 610 | |
| 611 | 611 | try { |
| 612 | 612 | self::initPaths(); |
| 613 | 613 | // setup 3rdparty autoloader |
| 614 | - $vendorAutoLoad = OC::$SERVERROOT . '/3rdparty/autoload.php'; |
|
| 614 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
| 615 | 615 | if (!file_exists($vendorAutoLoad)) { |
| 616 | 616 | 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".'); |
| 617 | 617 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $loaderEnd = microtime(true); |
| 629 | 629 | |
| 630 | 630 | // Enable lazy loading if activated |
| 631 | - \OC\AppFramework\Utility\SimpleContainer::$useLazyObjects = (bool)self::$config->getValue('enable_lazy_objects', true); |
|
| 631 | + \OC\AppFramework\Utility\SimpleContainer::$useLazyObjects = (bool) self::$config->getValue('enable_lazy_objects', true); |
|
| 632 | 632 | |
| 633 | 633 | // setup the basic server |
| 634 | 634 | self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
@@ -641,10 +641,10 @@ discard block |
||
| 641 | 641 | ); |
| 642 | 642 | $profiler->start(); |
| 643 | 643 | } catch (\Throwable $e) { |
| 644 | - logger('core')->error('Failed to start profiler: ' . $e->getMessage(), ['app' => 'base']); |
|
| 644 | + logger('core')->error('Failed to start profiler: '.$e->getMessage(), ['app' => 'base']); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if (self::$CLI && in_array('--' . \OCP\Console\ReservedOptions::DEBUG_LOG, $_SERVER['argv'])) { |
|
| 647 | + if (self::$CLI && in_array('--'.\OCP\Console\ReservedOptions::DEBUG_LOG, $_SERVER['argv'])) { |
|
| 648 | 648 | \OC\Core\Listener\BeforeMessageLoggedEventListener::setup(); |
| 649 | 649 | } |
| 650 | 650 | |
@@ -725,11 +725,11 @@ discard block |
||
| 725 | 725 | // Convert l10n string into regular string for usage in database |
| 726 | 726 | $staticErrors = []; |
| 727 | 727 | foreach ($errors as $error) { |
| 728 | - echo $error['error'] . "\n"; |
|
| 729 | - echo $error['hint'] . "\n\n"; |
|
| 728 | + echo $error['error']."\n"; |
|
| 729 | + echo $error['hint']."\n\n"; |
|
| 730 | 730 | $staticErrors[] = [ |
| 731 | - 'error' => (string)$error['error'], |
|
| 732 | - 'hint' => (string)$error['hint'], |
|
| 731 | + 'error' => (string) $error['error'], |
|
| 732 | + 'hint' => (string) $error['hint'], |
|
| 733 | 733 | ]; |
| 734 | 734 | } |
| 735 | 735 | |
@@ -847,11 +847,11 @@ discard block |
||
| 847 | 847 | $eventLogger->log('init', 'OC::init', $loaderStart, microtime(true)); |
| 848 | 848 | $eventLogger->start('runtime', 'Runtime'); |
| 849 | 849 | $eventLogger->start('request', 'Full request after boot'); |
| 850 | - register_shutdown_function(function () use ($eventLogger) { |
|
| 850 | + register_shutdown_function(function() use ($eventLogger) { |
|
| 851 | 851 | $eventLogger->end('request'); |
| 852 | 852 | }); |
| 853 | 853 | |
| 854 | - register_shutdown_function(function () { |
|
| 854 | + register_shutdown_function(function() { |
|
| 855 | 855 | $memoryPeak = memory_get_peak_usage(); |
| 856 | 856 | $logLevel = match (true) { |
| 857 | 857 | $memoryPeak > 500_000_000 => ILogger::FATAL, |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | default => null, |
| 861 | 861 | }; |
| 862 | 862 | if ($logLevel !== null) { |
| 863 | - $message = 'Request used more than 300 MB of RAM: ' . Util::humanFileSize($memoryPeak); |
|
| 863 | + $message = 'Request used more than 300 MB of RAM: '.Util::humanFileSize($memoryPeak); |
|
| 864 | 864 | $logger = Server::get(LoggerInterface::class); |
| 865 | 865 | $logger->log($logLevel, $message, ['app' => 'core']); |
| 866 | 866 | } |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | if ($systemConfig->getValue('installed', false) && !\OCP\Util::needUpgrade()) { |
| 876 | 876 | // NOTE: This will be replaced to use OCP |
| 877 | 877 | $userSession = Server::get(\OC\User\Session::class); |
| 878 | - $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
| 878 | + $userSession->listen('\OC\User', 'postLogin', function() use ($userSession) { |
|
| 879 | 879 | if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) { |
| 880 | 880 | // reset brute force delay for this IP address and username |
| 881 | 881 | $uid = $userSession->getUser()->getUID(); |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | private static function registerAppRestrictionsHooks(): void { |
| 928 | 928 | /** @var \OC\Group\Manager $groupManager */ |
| 929 | 929 | $groupManager = Server::get(\OCP\IGroupManager::class); |
| 930 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
| 930 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) { |
|
| 931 | 931 | $appManager = Server::get(\OCP\App\IAppManager::class); |
| 932 | 932 | $apps = $appManager->getEnabledAppsForGroup($group); |
| 933 | 933 | foreach ($apps as $appId) { |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | if (function_exists('opcache_reset')) { |
| 1001 | 1001 | opcache_reset(); |
| 1002 | 1002 | } |
| 1003 | - if (!((bool)$systemConfig->getValue('maintenance', false))) { |
|
| 1003 | + if (!((bool) $systemConfig->getValue('maintenance', false))) { |
|
| 1004 | 1004 | self::printUpgradePage($systemConfig); |
| 1005 | 1005 | exit(); |
| 1006 | 1006 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | |
| 1016 | 1016 | // Load minimum set of apps |
| 1017 | 1017 | if (!\OCP\Util::needUpgrade() |
| 1018 | - && !((bool)$systemConfig->getValue('maintenance', false))) { |
|
| 1018 | + && !((bool) $systemConfig->getValue('maintenance', false))) { |
|
| 1019 | 1019 | // For logged-in users: Load everything |
| 1020 | 1020 | if (Server::get(IUserSession::class)->isLoggedIn()) { |
| 1021 | 1021 | $appManager->loadApps(); |
@@ -1097,10 +1097,10 @@ discard block |
||
| 1097 | 1097 | if ($requestPath === '') { |
| 1098 | 1098 | // Someone is logged in |
| 1099 | 1099 | if (Server::get(IUserSession::class)->isLoggedIn()) { |
| 1100 | - header('Location: ' . Server::get(IURLGenerator::class)->linkToDefaultPageUrl()); |
|
| 1100 | + header('Location: '.Server::get(IURLGenerator::class)->linkToDefaultPageUrl()); |
|
| 1101 | 1101 | } else { |
| 1102 | 1102 | // Not handled and not logged in |
| 1103 | - header('Location: ' . Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.login.showLoginForm')); |
|
| 1103 | + header('Location: '.Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.login.showLoginForm')); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | return; |
| 1106 | 1106 | } |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | try { |
| 1184 | 1184 | $appAPIService = Server::get(OCA\AppAPI\Service\AppAPIService::class); |
| 1185 | 1185 | return $appAPIService->validateExAppRequestToNC($request); |
| 1186 | - } catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) { |
|
| 1186 | + } catch (\Psr\Container\NotFoundExceptionInterface | \Psr\Container\ContainerExceptionInterface $e) { |
|
| 1187 | 1187 | return false; |
| 1188 | 1188 | } |
| 1189 | 1189 | } |