Skip to content

Commit

Permalink
[BUGFIX] Correct constraint for fetching posts by year
Browse files Browse the repository at this point in the history
The calculation of the interval for years is wrong, the list does not show the contributions of a year, rather all contributions older than the current year.
  • Loading branch information
benjaminkott authored Mar 4, 2020
1 parent 569c2ff commit 45e8720
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function findByMonthAndYear(int $year, int $month = null)
$startDate = new \DateTimeImmutable(sprintf('%d-%d-1 00:00:00', $year, $month));
$endDate = new \DateTimeImmutable(sprintf('%d-%d-%d 23:59:59', $year, $month, (int)$startDate->format('t')));
} else {
$startDate = new \DateTimeImmutable(sprintf('%d-1-1 00:00:00', $month));
$startDate = new \DateTimeImmutable(sprintf('%d-1-1 00:00:00', $year));
$endDate = new \DateTimeImmutable(sprintf('%d-12-31 23:59:59', $year));
}
$constraints[] = $query->greaterThanOrEqual('publish_date', $startDate->getTimestamp());
Expand Down

0 comments on commit 45e8720

Please sign in to comment.