Skip to content

Commit

Permalink
Merge branch 'feature/62884-fix-redirects-filter' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoffmann1979 committed Apr 8, 2024
2 parents 43822b8 + f1b4aeb commit 9737e10
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,25 @@ public function listAction(Filter $filter = null, int $page = 1): ResponseInterf
$query->getRestrictions()->removeAll();
$query->select('uid')->from('sys_redirect')->where($query->expr()->eq('deleted', 1));
$foreignDeletedRedirects = $query->executeQuery()->fetchAllAssociative();
$additionalWhere = '';
$additonalConditions = [];
if (!empty($foreignDeletedRedirects)) {
$uidList = implode(',', array_column($foreignDeletedRedirects, 'uid'));

$additionalWhere = "deleted = 0 OR uid NOT IN ($uidList)";
if (null !== $filter) {
$additionalWhere = $filter->toAdditionWhere();
}
$additonalConditions[] = "(deleted = 0 OR uid NOT IN ($uidList))";
}
if (null !== $filter) {
$additonalConditions = $filter->toAdditionWhere();
}

$additonalWhere = '';
if (!empty($additonalConditions)) {
$additonalWhere = implode(' AND ', $additonalConditions);
}

$recordTree = new RecordTree();

$demands = $this->demandsFactory->createDemand();
$demands->addDemand(new SysRedirectDemand('sys_redirect', $additionalWhere, $recordTree));
$demands->addDemand(new SysRedirectDemand('sys_redirect', $additonalWhere, $recordTree));

$recordCollection = new RecordCollection();
$this->demandResolver->resolveDemand($demands, $recordCollection);
Expand Down
6 changes: 2 additions & 4 deletions Classes/Features/RedirectsSupport/Domain/Dto/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

use In2code\In2publishCore\Utility\DatabaseUtility;

use function implode;

class Filter
{
protected ?string $domain;
Expand Down Expand Up @@ -106,7 +104,7 @@ public function setPublishable(?string $publishable): void
* @SuppressWarnings(PHPMD.CyclomaticComplexity) The method is pretty easy to understand
* @SuppressWarnings(PHPMD.NPathComplexity) The method is pretty easy to understand
*/
public function toAdditionWhere(): string
public function toAdditionWhere(): array
{
$database = DatabaseUtility::buildLocalDatabaseConnection();
$where = [];
Expand Down Expand Up @@ -140,6 +138,6 @@ public function toAdditionWhere(): string
}
}

return implode(' AND ', $where);
return $where;
}
}
2 changes: 1 addition & 1 deletion Configuration/Backend/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if ($configContainer->get('features.redirectsSupport.enable')) {
$backendModulesToRegister['in2publish_core_m5'] = [
'parent' => 'site',
'position' => ['after' => 'redirects'],
'position' => ['after' => 'site_redirects'],
'access' => 'user',
'workspaces' => 'live',
'path' => '/module/in2publish_core/m5',
Expand Down

0 comments on commit 9737e10

Please sign in to comment.