diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-09-13 10:43:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 10:43:01 +0200 |
commit | 358eaba7dd45e5c5dbce44011bd7eadd88fe8534 (patch) | |
tree | 46799ecf5a1f46f6f90266bed81075d5f22073fb | |
parent | 471167019c7c9071fa815b2c92691f65370a43b9 (diff) | |
download | nextcloud-server-358eaba7dd45e5c5dbce44011bd7eadd88fe8534.tar.gz nextcloud-server-358eaba7dd45e5c5dbce44011bd7eadd88fe8534.zip |
Apply suggestions from code review
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
-rw-r--r-- | core/Migrations/Version23000Date20210906132259.php | 5 | ||||
-rw-r--r-- | lib/private/Security/RateLimiting/Backend/DatabaseBackend.php | 12 |
2 files changed, 8 insertions, 9 deletions
diff --git a/core/Migrations/Version23000Date20210906132259.php b/core/Migrations/Version23000Date20210906132259.php index b4568ab069c..e65846f40b9 100644 --- a/core/Migrations/Version23000Date20210906132259.php +++ b/core/Migrations/Version23000Date20210906132259.php @@ -31,13 +31,14 @@ class Version23000Date20210906132259 extends SimpleMigrationStep { 'notnull' => true, 'length' => 128, ]); - $table->addColumn('delete_after', 'datetime', [ + $table->addColumn('delete_after', Types::DATETIME, [ 'notnull' => true, ]); $table->addIndex(['hash'], 'ratelimit_hash_idx'); $table->addIndex(['delete_after'], 'ratelimit_delete_after_idx'); + return $schema; } - return $schema; + return null; } } diff --git a/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php b/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php index 2ba6dc73c47..5f579bfef85 100644 --- a/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php +++ b/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php @@ -73,21 +73,19 @@ class DatabaseBackend implements IBackend { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete(self::TABLE_NAME) ->where( - $qb->expr()->lte('delete_after', $qb->createParameter('currentTime')) - ) - ->setParameter('currentTime', $currentTime, 'datetime') + $qb->expr()->lte('delete_after', $qb->createNamedParameter($currentTime, IQueryBuilder::PARAM_DATE)) + ); ->executeStatement(); $qb = $this->dbConnection->getQueryBuilder(); - $qb->selectAlias($qb->createFunction('COUNT(*)'), 'count') + $qb->select($qb->func()->count()) ->from(self::TABLE_NAME) ->where( $qb->expr()->eq('hash', $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR)) ) ->andWhere( - $qb->expr()->gte('delete_after', $qb->createParameter('currentTime')) - ) - ->setParameter('currentTime', $currentTime, 'datetime'); + $qb->expr()->gte('delete_after', $qb->createNamedParameter($currentTime, IQueryBuilder::PARAM_DATE)) + ); $cursor = $qb->executeQuery(); $row = $cursor->fetch(); |