Skip to content

Commit

Permalink
[BUGFIX] Make any date manipulation only if at least one date paramet…
Browse files Browse the repository at this point in the history
…er exists (#1245)
  • Loading branch information
beatrycze-volk authored Jun 4, 2024
1 parent bff4419 commit f7a63eb
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,20 @@ public function mainAction(): void
}

// sanitize date search input
if (empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
$this->searchParams['dateFrom'] = '*';
}
if (empty($this->searchParams['dateTo']) && !empty($this->searchParams['dateFrom'])) {
$this->searchParams['dateTo'] = 'NOW';
}
if ($this->searchParams['dateFrom'] > $this->searchParams['dateTo']) {
$tmpDate = $this->searchParams['dateFrom'];
$this->searchParams['dateFrom'] = $this->searchParams['dateTo'];
$this->searchParams['dateTo'] = $tmpDate;
if (!empty($this->searchParams['dateFrom']) || !empty($this->searchParams['dateTo'])) {
if (empty($this->searchParams['dateFrom']) && !empty($this->searchParams['dateTo'])) {
$this->searchParams['dateFrom'] = '*';
}

if (empty($this->searchParams['dateTo']) && !empty($this->searchParams['dateFrom'])) {
$this->searchParams['dateTo'] = 'NOW';
}

if ($this->searchParams['dateFrom'] > $this->searchParams['dateTo']) {
$tmpDate = $this->searchParams['dateFrom'];
$this->searchParams['dateFrom'] = $this->searchParams['dateTo'];
$this->searchParams['dateTo'] = $tmpDate;
}
}

// Pagination of Results: Pass the currentPage to the fluid template to calculate current index of search result.
Expand Down

0 comments on commit f7a63eb

Please sign in to comment.