diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 5122106d8509b..7f565f62ef404 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -1266,11 +1266,6 @@
request->server]]>
-
-
- memoryCache]]>
-
-
diff --git a/build/rector.php b/build/rector.php
index 1cc613499c681..a119d84fd5995 100644
--- a/build/rector.php
+++ b/build/rector.php
@@ -52,6 +52,7 @@ public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedO
$config = RectorConfig::configure()
->withPaths([
$nextcloudDir . '/apps',
+ $nextcloudDir . '/status.php',
// $nextcloudDir . '/config',
// $nextcloudDir . '/core',
// $nextcloudDir . '/lib',
diff --git a/lib/autoloader.php b/lib/autoloader.php
index 41b272a457cc0..7084eb93c89d4 100644
--- a/lib/autoloader.php
+++ b/lib/autoloader.php
@@ -22,10 +22,8 @@ class Autoloader {
/**
* Optional low-latency memory cache for class to path mapping.
- *
- * @var \OC\Memcache\Cache
*/
- protected $memoryCache;
+ protected ?ICache $memoryCache = null;
/**
* Autoloader constructor.
@@ -127,15 +125,15 @@ protected function isValidPath(string $fullPath): bool {
* @throws AutoloadNotAllowedException
*/
public function load(string $class): bool {
+ if (class_exists($class, false)) {
+ return false;
+ }
+
$pathsToRequire = null;
if ($this->memoryCache) {
$pathsToRequire = $this->memoryCache->get($class);
}
- if (class_exists($class, false)) {
- return false;
- }
-
if (!is_array($pathsToRequire)) {
// No cache or cache miss
$pathsToRequire = [];
diff --git a/lib/base.php b/lib/base.php
index aa463e206a314..e9fdd48f90c8d 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -188,8 +188,6 @@ public static function initPaths(): void {
}
public static function checkConfig(): void {
- $l = Server::get(\OCP\L10N\IFactory::class)->get('lib');
-
// Create config if it does not already exist
$configFilePath = self::$configDir . '/config.php';
if (!file_exists($configFilePath)) {
@@ -201,6 +199,7 @@ public static function checkConfig(): void {
if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled()
|| !$configFileWritable && \OCP\Util::needUpgrade()) {
$urlGenerator = Server::get(IURLGenerator::class);
+ $l = Server::get(\OCP\L10N\IFactory::class)->get('lib');
if (self::$CLI) {
echo $l->t('Cannot write into "config" directory!') . "\n";
@@ -711,6 +710,7 @@ public static function init(): void {
self::performSameSiteCookieProtection($config);
if (!defined('OC_CONSOLE')) {
+ $eventLogger->start('check_server', 'Run a few configuration checks');
$errors = OC_Util::checkServer($systemConfig);
if (count($errors) > 0) {
if (!self::$CLI) {
@@ -745,6 +745,7 @@ public static function init(): void {
} elseif (self::$CLI && $config->getSystemValueBool('installed', false)) {
$config->deleteAppValue('core', 'cronErrors');
}
+ $eventLogger->end('check_server');
}
// User and Groups
@@ -752,6 +753,7 @@ public static function init(): void {
self::$server->getSession()->set('user_id', '');
}
+ $eventLogger->start('setup_backends', 'Setup group and user backends');
Server::get(\OCP\IUserManager::class)->registerBackend(new \OC\User\Database());
Server::get(\OCP\IGroupManager::class)->addBackend(new \OC\Group\Database());
@@ -770,6 +772,7 @@ public static function init(): void {
// Run upgrades in incognito mode
OC_User::setIncognitoMode(true);
}
+ $eventLogger->end('setup_backends');
self::registerCleanupHooks($systemConfig);
self::registerShareHooks($systemConfig);
diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php
index 2b04d2917305d..4e613703dece0 100644
--- a/lib/private/AppFramework/Bootstrap/Coordinator.php
+++ b/lib/private/AppFramework/Bootstrap/Coordinator.php
@@ -83,11 +83,12 @@ private function registerApps(array $appIds): void {
$appNameSpace = App::buildAppNamespace($appId);
$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
try {
- if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
+ if (class_exists($applicationClassName) && is_a($applicationClassName, IBootstrap::class, true)) {
$this->eventLogger->start("bootstrap:register_app:$appId:application", "Load `Application` instance for $appId");
try {
- /** @var IBootstrap|App $application */
- $apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
+ /** @var IBootstrap&App $application */
+ $application = $this->serverContainer->query($applicationClassName);
+ $apps[$appId] = $application;
} catch (QueryException $e) {
// Weird, but ok
$this->eventLogger->end("bootstrap:register_app:$appId");
diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php
index 24918992ea3a3..9af65a37ab8b6 100644
--- a/lib/private/AppFramework/Utility/SimpleContainer.php
+++ b/lib/private/AppFramework/Utility/SimpleContainer.php
@@ -153,13 +153,13 @@ public function registerService($name, Closure $closure, $shared = true) {
return $closure($this);
};
$name = $this->sanitizeName($name);
- if (isset($this[$name])) {
- unset($this[$name]);
+ if (isset($this->container[$name])) {
+ unset($this->container[$name]);
}
if ($shared) {
- $this[$name] = $wrapped;
+ $this->container[$name] = $wrapped;
} else {
- $this[$name] = $this->container->factory($wrapped);
+ $this->container[$name] = $this->container->factory($wrapped);
}
}
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php
index d073132516de5..2a60287254b83 100644
--- a/lib/private/Route/Router.php
+++ b/lib/private/Route/Router.php
@@ -54,9 +54,9 @@ public function __construct(
protected LoggerInterface $logger,
IRequest $request,
private IConfig $config,
- private IEventLogger $eventLogger,
+ protected IEventLogger $eventLogger,
private ContainerInterface $container,
- private IAppManager $appManager,
+ protected IAppManager $appManager,
) {
$baseUrl = \OC::$WEBROOT;
if (!($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
@@ -116,9 +116,11 @@ public function loadRoutes($app = null) {
$this->loaded = true;
$routingFiles = $this->getRoutingFiles();
+ $this->eventLogger->start('route:load:attributes', 'Loading Routes from attributes');
foreach (\OC_App::getEnabledApps() as $enabledApp) {
$this->loadAttributeRoutes($enabledApp);
}
+ $this->eventLogger->end('route:load:attributes');
} else {
if (isset($this->loadedApps[$app])) {
return;
@@ -140,6 +142,7 @@ public function loadRoutes($app = null) {
}
}
+ $this->eventLogger->start('route:load:files', 'Loading Routes from files');
foreach ($routingFiles as $app => $file) {
if (!isset($this->loadedApps[$app])) {
if (!$this->appManager->isAppLoaded($app)) {
@@ -160,6 +163,7 @@ public function loadRoutes($app = null) {
$this->root->addCollection($collection);
}
}
+ $this->eventLogger->end('route:load:files');
if (!isset($this->loadedApps['core'])) {
$this->loadedApps['core'] = true;
@@ -265,6 +269,7 @@ public function findMatchingRoute(string $url): array {
$this->loadRoutes();
}
+ $this->eventLogger->start('route:url:match', 'Symfony url matcher call');
$matcher = new UrlMatcher($this->root, $this->context);
try {
$parameters = $matcher->match($url);
@@ -283,6 +288,7 @@ public function findMatchingRoute(string $url): array {
throw $e;
}
}
+ $this->eventLogger->end('route:url:match');
$this->eventLogger->end('route:match');
return $parameters;
diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php
index 9f887b2d48abb..b5bcbdaeb6fd2 100644
--- a/lib/private/ServerContainer.php
+++ b/lib/private/ServerContainer.php
@@ -128,18 +128,17 @@ public function query(string $name, bool $autoload = true) {
} catch (QueryException $e) {
// Continue with general autoloading then
}
- }
-
- // In case the service starts with OCA\ we try to find the service in
- // the apps container first.
- if (($appContainer = $this->getAppContainerForService($name)) !== null) {
- try {
- return $appContainer->queryNoFallback($name);
- } catch (QueryException $e) {
- // Didn't find the service or the respective app container
- // In this case the service won't be part of the core container,
- // so we can throw directly
- throw $e;
+ // In case the service starts with OCA\ we try to find the service in
+ // the apps container first.
+ if (($appContainer = $this->getAppContainerForService($name)) !== null) {
+ try {
+ return $appContainer->queryNoFallback($name);
+ } catch (QueryException $e) {
+ // Didn't find the service or the respective app container
+ // In this case the service won't be part of the core container,
+ // so we can throw directly
+ throw $e;
+ }
}
} elseif (str_starts_with($name, 'OC\\Settings\\') && substr_count($name, '\\') >= 3) {
$segments = explode('\\', $name);
diff --git a/status.php b/status.php
index e4d4bab7e45be..e1b95d9396ba6 100644
--- a/status.php
+++ b/status.php
@@ -1,33 +1,42 @@
getSystemConfig();
+ $systemConfig = Server::get(SystemConfig::class);
$installed = (bool)$systemConfig->getValue('installed', false);
$maintenance = (bool)$systemConfig->getValue('maintenance', false);
# see core/lib/private/legacy/defaults.php and core/themes/example/defaults.php
# for description and defaults
- $defaults = new \OCP\Defaults();
+ $defaults = new Defaults();
+ $serverVersion = Server::get(ServerVersion::class);
$values = [
'installed' => $installed,
'maintenance' => $maintenance,
- 'needsDbUpgrade' => \OCP\Util::needUpgrade(),
- 'version' => implode('.', \OCP\Util::getVersion()),
- 'versionstring' => \OCP\Server::get(\OCP\ServerVersion::class)->getVersionString(),
+ 'needsDbUpgrade' => Util::needUpgrade(),
+ 'version' => implode('.', $serverVersion->getVersion()),
+ 'versionstring' => $serverVersion->getVersionString(),
'edition' => '',
'productname' => $defaults->getProductName(),
- 'extendedSupport' => \OCP\Util::hasExtendedSupport()
+ 'extendedSupport' => Util::hasExtendedSupport()
];
if (OC::$CLI) {
print_r($values);
@@ -38,5 +47,5 @@
}
} catch (Exception $ex) {
http_response_code(500);
- \OCP\Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'remote','exception' => $ex]);
+ Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'remote','exception' => $ex]);
}