Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"jangregor/phpstan-prophecy": "^2.1.11",
"justinrainbow/json-schema": "^6.5.2",
"laravel/framework": "^11.0 || ^12.0 || ^13.0",
"mcp/sdk": "^0.6",
"mcp/sdk": "^0.7",
"orchestra/testbench": "^10.9 || ^11.0",
"phpspec/prophecy-phpunit": "^2.2",
"phpstan/extension-installer": "^1.1",
Expand Down
4 changes: 4 additions & 0 deletions src/Doctrine/Orm/Filter/ExactFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q
$parameter = $context['parameter'];
$value = $parameter->getValue();

if (\is_array($value) && !array_is_list($value)) {
return;
}

if (null === $parameter->getProperty()) {
throw new InvalidArgumentException(\sprintf('The filter parameter with key "%s" must specify a property. Please provide the property explicitly.', $parameter->getKey()));
}
Expand Down
41 changes: 41 additions & 0 deletions src/Doctrine/Orm/Tests/Filter/ExactFilterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\Doctrine\Orm\Tests\Filter;

use ApiPlatform\Doctrine\Orm\Filter\ExactFilter;
use ApiPlatform\Doctrine\Orm\Tests\Fixtures\Entity\Dummy;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGenerator;
use ApiPlatform\Metadata\QueryParameter;
use Doctrine\ORM\QueryBuilder;
use PHPUnit\Framework\TestCase;

final class ExactFilterTest extends TestCase
{
private const ALIAS = 'o';
private const ASSOCIATIVE_DATE_FILTER_VALUE = ['strictly_before' => '2026-07-20'];
private const DATE_PROPERTY = 'dummyDate';

public function testExactFilterIgnoresAssociativeArrayValues(): void
{
$queryBuilder = $this->createMock(QueryBuilder::class);
$queryBuilder->method('getRootAliases')->willReturn([self::ALIAS]);
$queryBuilder->expects($this->never())->method('andWhere');
$queryBuilder->expects($this->never())->method('setParameter');

$parameter = (new QueryParameter(key: self::DATE_PROPERTY, property: self::DATE_PROPERTY))
->setValue(self::ASSOCIATIVE_DATE_FILTER_VALUE);

(new ExactFilter())->apply($queryBuilder, new QueryNameGenerator(), Dummy::class, context: ['parameter' => $parameter]);
}
}
4 changes: 3 additions & 1 deletion src/Laravel/ApiPlatformProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use Psr\Log\LoggerInterface;
use Symfony\AI\McpBundle\Controller\McpController;
use Symfony\AI\McpBundle\Http\MiddlewareFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -1342,7 +1343,8 @@ private function registerMcp(): void
$psrHttpFactory,
$httpFoundationFactory,
$psr17Factory,
$psr17Factory
$psr17Factory,
new MiddlewareFactory()
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mcp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"php": ">=8.2",
"api-platform/metadata": "^5.0@alpha",
"api-platform/json-schema": "^5.0@alpha",
"mcp/sdk": "^0.6",
"mcp/sdk": "^0.7",
"symfony/object-mapper": "^7.4 || ^8.0",
"symfony/polyfill-php85": "^1.32"
},
Expand Down
Loading