diff options
Diffstat (limited to 'lib/base.php')
-rw-r--r-- | lib/base.php | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/lib/base.php b/lib/base.php index c84a1246288..1f9caf473e2 100644 --- a/lib/base.php +++ b/lib/base.php @@ -43,7 +43,7 @@ class OC { */ private static string $SUBURI = ''; /** - * the Nextcloud root path for http requests (e.g. nextcloud/) + * the Nextcloud root path for http requests (e.g. /nextcloud) */ public static string $WEBROOT = ''; /** @@ -74,7 +74,7 @@ class OC { /** * @throws \RuntimeException when the 3rdparty directory is missing or - * the app path list is empty or contains an invalid path + * the app path list is empty or contains an invalid path */ public static function initPaths(): void { if (defined('PHPUNIT_CONFIG_DIR')) { @@ -88,7 +88,7 @@ class OC { } self::$config = new \OC\Config(self::$configDir); - OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"] ?? ''), strlen(OC::$SERVERROOT))); + OC::$SUBURI = str_replace('\\', '/', substr(realpath($_SERVER['SCRIPT_FILENAME'] ?? ''), strlen(OC::$SERVERROOT))); /** * FIXME: The following lines are required because we can't yet instantiate * Server::get(\OCP\IRequest::class) since \OC::$server does not yet exist. @@ -231,7 +231,7 @@ class OC { public static function checkMaintenanceMode(\OC\SystemConfig $systemConfig): void { // Allow ajax update script to execute without being stopped - if (((bool) $systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { + if (((bool)$systemConfig->getValue('maintenance', false)) && OC::$SUBURI != '/core/ajax/update.php') { // send http status 503 http_response_code(503); header('X-Nextcloud-Maintenance-Mode: 1'); @@ -387,8 +387,16 @@ class OC { $sessionName = OC_Util::getInstanceId(); try { + $logger = null; + if (Server::get(\OC\SystemConfig::class)->getValue('installed', false)) { + $logger = logger('core'); + } + // set the session name to the instance id - which is unique - $session = new \OC\Session\Internal($sessionName); + $session = new \OC\Session\Internal( + $sessionName, + $logger, + ); $cryptoWrapper = Server::get(\OC\Session\CryptoWrapper::class); $session = $cryptoWrapper->wrapSession($session); @@ -536,7 +544,7 @@ class OC { }); // calculate the root directories - OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); + OC::$SERVERROOT = str_replace('\\', '/', substr(__DIR__, 0, -4)); // register autoloader $loaderStart = microtime(true); @@ -649,6 +657,13 @@ class OC { $bootstrapCoordinator->runInitialRegistration(); $eventLogger->start('init_session', 'Initialize session'); + + // Check for PHP SimpleXML extension earlier since we need it before our other checks and want to provide a useful hint for web users + // see https://github.com/nextcloud/server/pull/2619 + if (!function_exists('simplexml_load_file')) { + throw new \OCP\HintException('The PHP SimpleXML/PHP-XML extension is not installed.', 'Install the extension or make sure it is enabled.'); + } + OC_App::loadApps(['session']); if (!self::$CLI) { self::initSession(); @@ -699,7 +714,7 @@ class OC { } // User and Groups - if (!$systemConfig->getValue("installed", false)) { + if (!$systemConfig->getValue('installed', false)) { self::$server->getSession()->set('user_id', ''); } @@ -732,7 +747,7 @@ class OC { self::registerAppRestrictionsHooks(); // Make sure that the application class is not loaded before the database is setup - if ($systemConfig->getValue("installed", false)) { + if ($systemConfig->getValue('installed', false)) { OC_App::loadApp('settings'); /* Build core application to make sure that listeners are registered */ Server::get(\OC\Core\Application::class); @@ -954,7 +969,7 @@ class OC { if (function_exists('opcache_reset')) { opcache_reset(); } - if (!((bool) $systemConfig->getValue('maintenance', false))) { + if (!((bool)$systemConfig->getValue('maintenance', false))) { self::printUpgradePage($systemConfig); exit(); } @@ -967,7 +982,7 @@ class OC { // Load minimum set of apps if (!\OCP\Util::needUpgrade() - && !((bool) $systemConfig->getValue('maintenance', false))) { + && !((bool)$systemConfig->getValue('maintenance', false))) { // For logged-in users: Load everything if (Server::get(IUserSession::class)->isLoggedIn()) { OC_App::loadApps(); @@ -986,7 +1001,7 @@ class OC { if (!self::$CLI) { try { - if (!((bool) $systemConfig->getValue('maintenance', false)) && !\OCP\Util::needUpgrade()) { + if (!((bool)$systemConfig->getValue('maintenance', false)) && !\OCP\Util::needUpgrade()) { OC_App::loadApps(['filesystem', 'logging']); OC_App::loadApps(); } |