Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SnapshotManager: use QueryBuilder #1446

Merged
merged 10 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require": {
"php": "^7.4 || ^8.0",
"cocur/slugify": "^3.0 || ^4.0",
"doctrine/doctrine-bundle": "^1.12.3 || ^2.0",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/persistence": "^1.3.4 || ^2.0",
Hanmac marked this conversation as resolved.
Show resolved Hide resolved
"sonata-project/admin-bundle": "^3.99",
"sonata-project/block-bundle": "^3.20",
Expand Down Expand Up @@ -73,6 +73,7 @@
"vimeo/psalm": "^4.7.2"
},
"conflict": {
"doctrine/orm": "<2.8",
"friendsofsymfony/rest-bundle": "<2.1",
"jms/serializer": "<0.13",
"sonata-project/cache": "<2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/SnapshotManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function cleanup(PageInterface $page, $keep)

// Subquery DQL doesn't support Limit
$innerQb
->select('i.id')
->select('DISTINCT i.id')
Hanmac marked this conversation as resolved.
Show resolved Hide resolved
Hanmac marked this conversation as resolved.
Show resolved Hide resolved
->where($expr->eq('i.page', $page->getId()))
->orderBy($ifNullExpr, Criteria::DESC)
->addOrderBy('i.publicationDateEnd', Criteria::DESC)
Expand All @@ -254,7 +254,7 @@ public function cleanup(PageInterface $page, $keep)
if (method_exists($query, 'getSingleColumnResult')) {
Hanmac marked this conversation as resolved.
Show resolved Hide resolved
$innerArray = $query->getSingleColumnResult();
} else {
$innerArray = array_column($query->getScalarResult(), 'id');
$innerArray = array_column($query->getArrayResult(), 'id');
}

$qb = $this->getRepository()->createQueryBuilder('s');
Expand Down