Skip to content

Commit 25b9cbe

Browse files
szaimenmiaulalala
andcommitted
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>
1 parent 46f61ca commit 25b9cbe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/private/CapabilitiesManager.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCP\Capabilities\ICapability;
1313
use OCP\Capabilities\IInitialStateExcludedCapability;
1414
use OCP\Capabilities\IPublicCapability;
15+
use OCP\IConfig;
1516
use OCP\ILogger;
1617
use Psr\Log\LoggerInterface;
1718

@@ -56,11 +57,15 @@ public function getCapabilities(bool $public = false, bool $initialState = false
5657
// that we would otherwise inject to every page load
5758
continue;
5859
}
60+
5961
$startTime = microtime(true);
6062
$capabilities = array_replace_recursive($capabilities, $c->getCapabilities());
6163
$endTime = microtime(true);
64+
65+
// Only check execution time if debug mode is enabled
66+
$debugMode = \OCP\Server::get(IConfig::class)->getSystemValueBool('debug', false);
6267
$timeSpent = $endTime - $startTime;
63-
if ($timeSpent > self::ACCEPTABLE_LOADING_TIME) {
68+
if ($debugMode && $timeSpent > self::ACCEPTABLE_LOADING_TIME) {
6469
$logLevel = match (true) {
6570
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 16 => ILogger::FATAL,
6671
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 8 => ILogger::ERROR,

0 commit comments

Comments
 (0)