diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php index 494504af3d80a..1f2d154ad9ee8 100644 --- a/lib/private/CapabilitiesManager.php +++ b/lib/private/CapabilitiesManager.php @@ -12,6 +12,7 @@ use OCP\Capabilities\ICapability; use OCP\Capabilities\IInitialStateExcludedCapability; use OCP\Capabilities\IPublicCapability; +use OCP\IConfig; use OCP\ILogger; use Psr\Log\LoggerInterface; @@ -56,11 +57,15 @@ public function getCapabilities(bool $public = false, bool $initialState = false // that we would otherwise inject to every page load continue; } + $startTime = microtime(true); $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); $endTime = microtime(true); + + // Only check execution time if debug mode is enabled + $debugMode = \OCP\Server::get(IConfig::class)->getSystemValueBool('debug', false); $timeSpent = $endTime - $startTime; - if ($timeSpent > self::ACCEPTABLE_LOADING_TIME) { + if ($debugMode && $timeSpent > self::ACCEPTABLE_LOADING_TIME) { $logLevel = match (true) { $timeSpent > self::ACCEPTABLE_LOADING_TIME * 16 => ILogger::FATAL, $timeSpent > self::ACCEPTABLE_LOADING_TIME * 8 => ILogger::ERROR,