mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 04:03:12 +08:00
Fix error when setting max results in a delete query
This commit is contained in:
@@ -15,9 +15,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
*/
|
||||
class ApiKeyRepository extends EntitySpecificationRepository implements ApiKeyRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function createInitialApiKey(string $apiKey): ApiKey|null
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
@@ -42,14 +40,13 @@ class ApiKeyRepository extends EntitySpecificationRepository implements ApiKeyRe
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function nameExists(string $name): bool
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
$qb->select('a.id')
|
||||
->from(ApiKey::class, 'a');
|
||||
->from(ApiKey::class, 'a')
|
||||
->setMaxResults(1);
|
||||
|
||||
$this->queryBuilderByName($qb, $name);
|
||||
|
||||
@@ -60,9 +57,7 @@ class ApiKeyRepository extends EntitySpecificationRepository implements ApiKeyRe
|
||||
return $query->getOneOrNullResult() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function deleteByName(string $name): int
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
@@ -79,7 +74,6 @@ class ApiKeyRepository extends EntitySpecificationRepository implements ApiKeyRe
|
||||
private function queryBuilderByName(QueryBuilder $qb, string $name): void
|
||||
{
|
||||
$qb->where($qb->expr()->eq('a.name', ':name'))
|
||||
->setParameter('name', $name)
|
||||
->setMaxResults(1);
|
||||
->setParameter('name', $name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ readonly class ApiKeyService implements ApiKeyServiceInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function create(ApiKeyMeta $apiKeyMeta): ApiKey
|
||||
{
|
||||
return $this->em->wrapInTransaction(function () use ($apiKeyMeta) {
|
||||
@@ -68,9 +66,7 @@ readonly class ApiKeyService implements ApiKeyServiceInterface
|
||||
return new ApiKeyCheckResult($apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function deleteByName(string $apiKeyName): void
|
||||
{
|
||||
$affectedResults = $this->repo->deleteByName($apiKeyName);
|
||||
@@ -79,9 +75,7 @@ readonly class ApiKeyService implements ApiKeyServiceInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function disableByName(string $apiKeyName): ApiKey
|
||||
{
|
||||
$apiKey = $this->repo->findOneBy(['name' => $apiKeyName]);
|
||||
@@ -109,9 +103,7 @@ readonly class ApiKeyService implements ApiKeyServiceInterface
|
||||
return $this->repo->findBy($conditions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function renameApiKey(Renaming $apiKeyRenaming): ApiKey
|
||||
{
|
||||
$apiKey = $this->repo->findOneBy(['name' => $apiKeyRenaming->oldName]);
|
||||
|
||||
Reference in New Issue
Block a user