diff --git a/Classes/Domain/Model/Transfer/FilterDto.php b/Classes/Domain/Model/Transfer/FilterDto.php index 4945b770..a62cf119 100644 --- a/Classes/Domain/Model/Transfer/FilterDto.php +++ b/Classes/Domain/Model/Transfer/FilterDto.php @@ -658,7 +658,7 @@ public function getEndTimeForFilter(bool $shortmode = false): DateTime */ protected function getStartTimeFromTimePeriod(): DateTime { - if ($this->getTimePeriod() === self::PERIOD_ALL || $this->isOnlySearchtermGiven()) { + if ($this->getTimePeriod() === self::PERIOD_ALL) { $time = new DateTime(); $time->setTimestamp(0); } elseif ($this->getTimePeriod() === self::PERIOD_THISYEAR) { diff --git a/Classes/Domain/Repository/AbstractRepository.php b/Classes/Domain/Repository/AbstractRepository.php index 2f87c4e1..90b2b37d 100644 --- a/Classes/Domain/Repository/AbstractRepository.php +++ b/Classes/Domain/Repository/AbstractRepository.php @@ -9,6 +9,7 @@ use In2code\Lux\Domain\Model\Pagevisit; use In2code\Lux\Domain\Model\Transfer\FilterDto; use In2code\Lux\Domain\Model\Visitor; +use In2code\Lux\Utility\BackendUtility; use In2code\Lux\Utility\StringUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -85,6 +86,10 @@ protected function extendLogicalAndWithFilterConstraintsForSite( array $logicalAnd, string $tablePrefix = '' ): array { + if (BackendUtility::isAdministrator() && $filter->isSiteSet() === false) { + // Prevent join to pagevisit table if not needed (to avoid empty result problems on specific search) + return $logicalAnd; + } $field = ($tablePrefix ? $tablePrefix . '.' : '') . 'site'; $logicalAnd[] = $query->in($field, $filter->getSitesForFilter()); return $logicalAnd; diff --git a/Classes/Domain/Repository/VisitorRepository.php b/Classes/Domain/Repository/VisitorRepository.php index a9180417..037594d4 100644 --- a/Classes/Domain/Repository/VisitorRepository.php +++ b/Classes/Domain/Repository/VisitorRepository.php @@ -708,7 +708,7 @@ protected function extendLogicalAndWithFilterConstraints( ) ); - if ($filter->getSearchterms() !== []) { + if ($filter->isSearchtermSet()) { $logicalOr = []; foreach ($filter->getSearchterms() as $searchterm) { if (MathUtility::canBeInterpretedAsInteger($searchterm)) { @@ -722,16 +722,16 @@ protected function extendLogicalAndWithFilterConstraints( } $logicalAnd[] = $query->logicalOr(...$logicalOr); } - if ($filter->getIdentified() > FilterDto::IDENTIFIED_ALL) { + if ($filter->isIdentifiedSet()) { $logicalAnd[] = $query->equals('identified', $filter->getIdentified() === FilterDto::IDENTIFIED_IDENTIFIED); } - if ($filter->getPid() !== '') { + if ($filter->isPidSet()) { $logicalAnd[] = $query->equals('pagevisits.page.uid', (int)$filter->getPid()); } - if ($filter->getScoring() > 0) { + if ($filter->isScoringSet()) { $logicalAnd[] = $query->greaterThan('scoring', $filter->getScoring()); } - if ($filter->getCategoryScoring() !== null) { + if ($filter->isCategoryScoringSet()) { $logicalAnd[] = $query->equals('categoryscorings.category', $filter->getCategoryScoring()); $logicalAnd[] = $query->greaterThan('categoryscorings.scoring', 0); } @@ -745,7 +745,7 @@ protected function extendLogicalAndWithFilterConstraints( protected function getOrderingsArrayByFilterDto(FilterDto $filter): array { $orderings = ['identified' => QueryInterface::ORDER_DESCENDING]; - if ($filter->getCategoryScoring() === null) { + if ($filter->isCategoryScoringSet() === false) { $orderings['scoring'] = QueryInterface::ORDER_DESCENDING; } else { $orderings['categoryscorings.scoring'] = QueryInterface::ORDER_DESCENDING; @@ -797,7 +797,7 @@ protected function extendWhereClauseWithFilterSearchterms( protected function extendWhereClauseWithFilterIdentified(FilterDto $filter): string { $sql = ''; - if ($filter->getIdentified() > FilterDto::IDENTIFIED_ALL) { + if ($filter->isIdentifiedSet()) { $sql .= ' and v.identified=' . (int)($filter->getIdentified() === FilterDto::IDENTIFIED_IDENTIFIED); } return $sql;