fix(CapabilitiesManager): only check execution time if debug mode is enabled

Signed-off-by: Simon L. <szaimen@e.mail.de>
Co-Authored-By: Anna <anna@nextcloud.com>
pull/58971/head
Simon L. 5 months ago
parent ec03e87675
commit 3e6d2dc794
  1. 7
      lib/private/CapabilitiesManager.php

@ -13,6 +13,7 @@ use OCP\AppFramework\QueryException;
use OCP\Capabilities\ICapability;
use OCP\Capabilities\IInitialStateExcludedCapability;
use OCP\Capabilities\IPublicCapability;
use OCP\IConfig;
use OCP\ILogger;
use Psr\Log\LoggerInterface;
@ -57,11 +58,15 @@ class CapabilitiesManager {
// 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,

Loading…
Cancel
Save