Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Let the database count the entries
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Aug 19, 2020
commit cdb36c8eadc2b9c2a864941e8d1e585c8f3e18c5
8 changes: 6 additions & 2 deletions lib/private/Security/Bruteforce/Throttler.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function getDelay($ip, $action = '') {
$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())));
Expand All @@ -237,7 +237,11 @@ public function getDelay($ip, $action = '') {
$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;
Expand Down