diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-04-05 18:32:46 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-04-07 17:33:29 +0200 |
commit | 69b36fc2c5835d854279b51ff795312f988218a6 (patch) | |
tree | 96f3ef2614405b88fe9d64cacd8367b975a921a0 /lib/private/CapabilitiesManager.php | |
parent | 9c84aa5870204a871024ca18b4994ed40defdd9b (diff) | |
download | nextcloud-server-69b36fc2c5835d854279b51ff795312f988218a6.tar.gz nextcloud-server-69b36fc2c5835d854279b51ff795312f988218a6.zip |
Don't inject Bruteforce capability info in the webui
This capability do DB access and as far I know is not used by the webui.
This remove one DB query for each page load.
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/CapabilitiesManager.php')
-rw-r--r-- | lib/private/CapabilitiesManager.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php index 16f9bd64252..ff92ebb5444 100644 --- a/lib/private/CapabilitiesManager.php +++ b/lib/private/CapabilitiesManager.php @@ -31,6 +31,7 @@ namespace OC; use OCP\AppFramework\QueryException; use OCP\Capabilities\ICapability; use OCP\Capabilities\IPublicCapability; +use OCP\Capabilities\IInitialStateExcludedCapability; use Psr\Log\LoggerInterface; class CapabilitiesManager { @@ -52,7 +53,7 @@ class CapabilitiesManager { * @throws \InvalidArgumentException * @return array */ - public function getCapabilities(bool $public = false) : array { + public function getCapabilities(bool $public = false, bool $initialState = false) : array { $capabilities = []; foreach ($this->capabilities as $capability) { try { @@ -66,6 +67,11 @@ class CapabilitiesManager { if ($c instanceof ICapability) { if (!$public || $c instanceof IPublicCapability) { + if ($initialState && ($c instanceof IInitialStateExcludedCapability)) { + // Remove less important capabilities information that are expensive to query + // that we would otherwise inject to every page load + continue; + } $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); } } else { |