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:
@@ -19,9 +19,7 @@ readonly class ShortUrlRedirectRuleService implements ShortUrlRedirectRuleServic
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function rulesForShortUrl(ShortUrl $shortUrl): array
|
||||
{
|
||||
return $this->em->getRepository(ShortUrlRedirectRule::class)->findBy(
|
||||
@@ -30,9 +28,7 @@ readonly class ShortUrlRedirectRuleService implements ShortUrlRedirectRuleServic
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function setRulesForShortUrl(ShortUrl $shortUrl, RedirectRulesData $data): array
|
||||
{
|
||||
$rules = [];
|
||||
@@ -54,9 +50,7 @@ readonly class ShortUrlRedirectRuleService implements ShortUrlRedirectRuleServic
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function saveRulesForShortUrl(ShortUrl $shortUrl, array $rules): void
|
||||
{
|
||||
$normalizedAndDetachedRules = map($rules, function (ShortUrlRedirectRule $rule, int|string|float $priority) {
|
||||
|
||||
@@ -12,9 +12,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
class ShortUrlsListFiltering extends ShortUrlsCountFiltering
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function __construct(
|
||||
public readonly int|null $limit = null,
|
||||
public readonly int|null $offset = null,
|
||||
|
||||
@@ -16,9 +16,7 @@ use function sprintf;
|
||||
/** @extends EntitySpecificationRepository<ShortUrl> */
|
||||
class ExpiredShortUrlsRepository extends EntitySpecificationRepository implements ExpiredShortUrlsRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function delete(ExpiredShortUrlsConditions $conditions): int
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
@@ -27,9 +25,7 @@ class ExpiredShortUrlsRepository extends EntitySpecificationRepository implement
|
||||
return $this->applyConditions($qb, $conditions, fn () => (int) $qb->getQuery()->execute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function dryCount(ExpiredShortUrlsConditions $conditions): int
|
||||
{
|
||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
||||
|
||||
@@ -19,9 +19,7 @@ readonly class ShortUrlListService implements ShortUrlListServiceInterface
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function listShortUrls(ShortUrlsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
$defaultDomain = $this->urlShortenerOptions->defaultDomain;
|
||||
|
||||
@@ -24,17 +24,13 @@ readonly class TagService implements TagServiceInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function listTags(TagsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
return $this->createPaginator(new TagsPaginatorAdapter($this->repo, $params, $apiKey), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function tagsInfo(TagsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
return $this->createPaginator(new TagsInfoPaginatorAdapter($this->repo, $params, $apiKey), $params);
|
||||
@@ -54,9 +50,7 @@ readonly class TagService implements TagServiceInterface
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function deleteTags(array $tagNames, ApiKey|null $apiKey = null): void
|
||||
{
|
||||
if (ApiKey::isShortUrlRestricted($apiKey)) {
|
||||
@@ -66,9 +60,7 @@ readonly class TagService implements TagServiceInterface
|
||||
$this->repo->deleteByName($tagNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function renameTag(Renaming $renaming, ApiKey|null $apiKey = null): Tag
|
||||
{
|
||||
if (ApiKey::isShortUrlRestricted($apiKey)) {
|
||||
|
||||
@@ -64,9 +64,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function visitsForShortUrl(
|
||||
ShortUrlIdentifier $identifier,
|
||||
VisitsParams $params,
|
||||
@@ -87,9 +85,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function visitsForTag(string $tag, WithDomainVisitsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
/** @var TagRepository $tagRepo */
|
||||
@@ -104,9 +100,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
return $this->createPaginator(new TagVisitsPaginatorAdapter($repo, $tag, $params, $apiKey), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function visitsForDomain(string $domain, VisitsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
/** @var DomainRepository $domainRepo */
|
||||
@@ -121,9 +115,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
return $this->createPaginator(new DomainVisitsPaginatorAdapter($repo, $domain, $params, $apiKey), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function orphanVisits(OrphanVisitsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
/** @var VisitRepository $repo */
|
||||
|
||||
@@ -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