summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-03-19 13:01:34 +0100
committerJoas Schilling <coding@schilljs.com>2020-08-19 11:20:35 +0200
commitcdb36c8eadc2b9c2a864941e8d1e585c8f3e18c5 (patch)
treee5784d319231b736047e39cef43e806e69aec33c /lib
parente66bc4a8a74ad6071569ea707e986a0e21aca66d (diff)
downloadnextcloud-server-cdb36c8eadc2b9c2a864941e8d1e585c8f3e18c5.tar.gz
nextcloud-server-cdb36c8eadc2b9c2a864941e8d1e585c8f3e18c5.zip
Let the database count the entries
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Security/Bruteforce/Throttler.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php
index 8e485046602..e5d3c3503ba 100644
--- a/lib/private/Security/Bruteforce/Throttler.php
+++ b/lib/private/Security/Bruteforce/Throttler.php
@@ -228,7 +228,7 @@ class Throttler {
$cutoffTime = $this->getCutoffTimestamp();
$qb = $this->db->getQueryBuilder();
- $qb->select('*')
+ $qb->select($qb->func()->count('*', 'attempts'))
->from('bruteforce_attempts')
->where($qb->expr()->gt('occurred', $qb->createNamedParameter($cutoffTime)))
->andWhere($qb->expr()->eq('subnet', $qb->createNamedParameter($ipAddress->getSubnet())));
@@ -237,7 +237,11 @@ class Throttler {
$qb->andWhere($qb->expr()->eq('action', $qb->createNamedParameter($action)));
}
- $attempts = count($qb->execute()->fetchAll());
+ $result = $qb->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ $attempts = (int) $row['attempts'];
if ($attempts === 0) {
return 0;