Skip to content

Commit

Permalink
fix: correct escape filter condition
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceAmstoutz committed Dec 10, 2024
1 parent d9bc540 commit 7047de6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/Doctrine/Odm/Filter/OrderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ public function __construct(?ManagerRegistry $managerRegistry = null, string $or
*/
public function apply(Builder $aggregationBuilder, string $resourceClass, ?Operation $operation = null, array &$context = []): void
{
if (!isset($context['filters'][$this->orderParameterName]) || !\is_array($context['filters'][$this->orderParameterName])) {
parent::apply($aggregationBuilder, $resourceClass, $operation, $context);

if (isset($context['filters']) && !isset($context['filters'][$this->orderParameterName]) && !isset($context['parameter'])) {
return;
}

Expand Down
9 changes: 7 additions & 2 deletions src/Doctrine/Orm/Filter/OrderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ public function __construct(?ManagerRegistry $managerRegistry = null, string $or
*/
public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (!isset($context['filters'][$this->orderParameterName]) || !\is_array($context['filters'][$this->orderParameterName])) {
parent::apply($queryBuilder, $queryNameGenerator, $resourceClass, $operation, $context);
if (isset($context['filters']) && !isset($context['filters'][$this->orderParameterName]) && !isset($context['parameter'])) {
return;
}

$parameter = $context['parameter'] ?? null;
if (null !== ($value = $context['filters'][$parameter?->getProperty()] ?? null)) {
$this->filterProperty($this->denormalizePropertyName($parameter->getProperty()), $value, $queryBuilder, $queryNameGenerator, $resourceClass, $operation, $context);

return;
}
Expand Down

0 comments on commit 7047de6

Please sign in to comment.