Skip to content

Commit

Permalink
[BUGFIX] Fix resolving of SelectMm demands containing ORDER BY statem…
Browse files Browse the repository at this point in the history
…ents in the additionalWhere clause

Related: https://projekte.in2code.de/issues/66385
  • Loading branch information
tinzog committed Oct 31, 2024
1 parent dcaa090 commit d28f988
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class AbstractProcessor implements TcaPreProcessor
{
use ExcludedTablesServiceInjection;

public const ADDITIONAL_ORDER_BY_PATTERN = '/(?P<where>.*)ORDER[\s\n]+BY[\s\n]+(?P<col>\w+(\.\w+)?)(?P<dir>\s(DESC|ASC))?/is';
public const ADDITIONAL_ORDER_BY_PATTERN = '/^(.*?)ORDER\s+BY\s+\w+(?:\.\w+)?(?:\s+(?:DESC|ASC))?(?:\s+(AND\s+.*|OR\s+.*)|$)/is';
protected ContainerInterface $container;

/**
Expand Down
4 changes: 3 additions & 1 deletion Classes/Component/Core/Resolver/SelectMmResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function resolve(Demands $demands, Record $record): void
$this->column,
);
if (1 === preg_match(AbstractProcessor::ADDITIONAL_ORDER_BY_PATTERN, $additionalWhere, $matches)) {
$additionalWhere = $matches['where'];
$statementBeforeOrderBy = $matches[1] ?? '';
$statementAfterOrderBy = $matches[2] ?? '';
$additionalWhere = trim($statementBeforeOrderBy . ' ' . $statementAfterOrderBy);
}

$value = $record->getId();
Expand Down

0 comments on commit d28f988

Please sign in to comment.