Skip to content

Commit 25968ac

Browse files
committed
Merge branch '4.2'
# Conflicts: # CHANGELOG.md # src/JsonLd/Serializer/ItemNormalizer.php # src/Metadata/Tests/Property/Factory/SerializerPropertyMetadataFactoryTest.php # src/Serializer/AbstractItemNormalizer.php # src/Symfony/Bundle/Resources/config/jsonld.php
2 parents 32e9484 + edc7a37 commit 25968ac

File tree

91 files changed

+734
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+734
-135
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111

1212
* When using `output` with `itemUriTemplate` on a collection operation, the JSON-LD `@type` will now use the resource class name instead of the output DTO class name for semantic consistency with `itemUriTemplate` behavior.
1313

14+
## v4.2.16
15+
16+
### Bug fixes
17+
18+
* [07100d501](https://github.com/api-platform/core/commit/07100d501be4ab88ca8154def51b9154e33bc126) fix(hydra): use standard xsd prefix and remove duplicate context namespaces (#7740)
19+
* [3d8e4fb05](https://github.com/api-platform/core/commit/3d8e4fb05f5e89847eb805f4d7c80dd5bda17c5d) fix(laravel): support numeric float types in eloquent metadata factory (#7730)
20+
* [4f307d3ce](https://github.com/api-platform/core/commit/4f307d3cea91bd858614c9250579b0e64854f513) fix(doctrine): skip uninitialized properties in handleLazyObjectRelations (#7738)
21+
* [6f85f2aa3](https://github.com/api-platform/core/commit/6f85f2aa3157149ac16b87605f02e6468f33823b) fix(metadata): use entity class from stateOptions for filter property resolution (#7739)
22+
* [70b17ce56](https://github.com/api-platform/core/commit/70b17ce5611d546ff4a70deaeec3091d5e1ef739) fix(doctrine): allow both uppercase and lowercase order direction in OrderFilter schema (#7741) (#7742)
23+
* [d70eec574](https://github.com/api-platform/core/commit/d70eec57439e35aa8f3144048d620a07aeb9ec26) fix(serializer): prevent context leakage with service-based entity resolution (#7756)
24+
1425
## v4.2.15
1526

1627
### Bug fixes

src/Doctrine/Common/Tests/CollectionPaginatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
use ApiPlatform\Doctrine\Common\CollectionPaginator;
1717
use Doctrine\Common\Collections\ArrayCollection;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\TestCase;
1920

2021
class CollectionPaginatorTest extends TestCase
2122
{
22-
#[\PHPUnit\Framework\Attributes\DataProvider('initializeProvider')]
23+
#[DataProvider('initializeProvider')]
2324
public function testInitialize($results, $currentPage, $itemsPerPage, $totalItems, $lastPage, $currentItems): void
2425
{
2526
$results = new ArrayCollection($results);

src/Doctrine/Common/Tests/SelectablePaginatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
use ApiPlatform\Doctrine\Common\SelectablePaginator;
1717
use Doctrine\Common\Collections\ArrayCollection;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\TestCase;
1920

2021
class SelectablePaginatorTest extends TestCase
2122
{
22-
#[\PHPUnit\Framework\Attributes\DataProvider('initializeProvider')]
23+
#[DataProvider('initializeProvider')]
2324
public function testInitialize($results, $currentPage, $itemsPerPage, $totalItems, $lastPage, $currentItems): void
2425
{
2526
$results = new ArrayCollection($results);

src/Doctrine/Common/Tests/SelectablePartialPaginatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
use ApiPlatform\Doctrine\Common\SelectablePartialPaginator;
1717
use Doctrine\Common\Collections\ArrayCollection;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\TestCase;
1920

2021
class SelectablePartialPaginatorTest extends TestCase
2122
{
22-
#[\PHPUnit\Framework\Attributes\DataProvider('initializeProvider')]
23+
#[DataProvider('initializeProvider')]
2324
public function testInitialize($results, $currentPage, $itemsPerPage, $currentItems): void
2425
{
2526
$results = new ArrayCollection($results);

src/Doctrine/Common/Tests/State/PersistProcessorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Doctrine\ORM\Mapping\ClassMetadata as ORMClassMetadata;
2424
use Doctrine\Persistence\ManagerRegistry;
2525
use Doctrine\Persistence\ObjectManager;
26+
use PHPUnit\Framework\Attributes\DataProvider;
2627
use PHPUnit\Framework\TestCase;
2728
use Prophecy\PhpUnit\ProphecyTrait;
2829
use Prophecy\Prediction\CallPrediction;
@@ -93,7 +94,7 @@ public static function getTrackingPolicyParameters(): array
9394
];
9495
}
9596

96-
#[\PHPUnit\Framework\Attributes\DataProvider('getTrackingPolicyParameters')]
97+
#[DataProvider('getTrackingPolicyParameters')]
9798
public function testTrackingPolicy(string $metadataClass, bool $deferredExplicit, bool $persisted): void
9899
{
99100
$dummy = new Dummy();
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Doctrine\Odm\Serializer;
15+
16+
use ApiPlatform\Doctrine\Odm\State\Options;
17+
use ApiPlatform\Metadata\Operation;
18+
use ApiPlatform\Metadata\Util\ClassInfoTrait;
19+
use ApiPlatform\Serializer\OperationResourceClassResolver;
20+
21+
/**
22+
* Doctrine ODM operation resource resolver.
23+
*
24+
* Handles document-to-resource mappings from Doctrine ODM's stateOptions.
25+
*
26+
* @author Kévin Dunglas <dunglas@gmail.com>
27+
*/
28+
final class DoctrineOdmOperationResourceClassResolver extends OperationResourceClassResolver
29+
{
30+
use ClassInfoTrait;
31+
32+
public function resolve(object|string $resource, Operation $operation): string
33+
{
34+
if (\is_string($resource)) {
35+
return $resource;
36+
}
37+
38+
$objectClass = $this->getObjectClass($resource);
39+
$stateOptions = $operation->getStateOptions();
40+
41+
// Doctrine ODM: Check for document class in stateOptions
42+
if ($stateOptions instanceof Options) {
43+
$documentClass = $stateOptions->getDocumentClass();
44+
45+
// Validate object matches the backing document class
46+
if ($documentClass && is_a($objectClass, $documentClass, true)) {
47+
return $operation->getClass();
48+
}
49+
}
50+
51+
// Fallback to core behavior
52+
return parent::resolve($resource, $operation);
53+
}
54+
}

src/Doctrine/Odm/Tests/DoctrineMongoDbOdmFilterTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\ODM\MongoDB\DocumentManager;
1818
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
1919
use Doctrine\Persistence\ManagerRegistry;
20+
use PHPUnit\Framework\Attributes\DataProvider;
2021
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2122

2223
/**
@@ -45,7 +46,7 @@ protected function setUp(): void
4546
$this->repository = $this->manager->getRepository($this->resourceClass);
4647
}
4748

48-
#[\PHPUnit\Framework\Attributes\DataProvider('provideApplyTestData')]
49+
#[DataProvider('provideApplyTestData')]
4950
public function testApply(?array $properties, array $filterParameters, array $expectedPipeline, ?callable $factory = null, ?string $resourceClass = null): void
5051
{
5152
$this->doTestApply($properties, $filterParameters, $expectedPipeline, $factory, $resourceClass);

src/Doctrine/Odm/Tests/Metadata/Resource/DoctrineMongoDbOdmResourceCollectionMetadataFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
2828
use Doctrine\ODM\MongoDB\DocumentManager;
2929
use Doctrine\Persistence\ManagerRegistry;
30+
use PHPUnit\Framework\Attributes\DataProvider;
3031
use PHPUnit\Framework\TestCase;
3132
use Prophecy\PhpUnit\ProphecyTrait;
3233

@@ -70,7 +71,7 @@ public function testWithoutManager(): void
7071
$this->assertNull($resourceMetadataCollection->getOperation('graphql_get')->getProvider());
7172
}
7273

73-
#[\PHPUnit\Framework\Attributes\DataProvider('operationProvider')]
74+
#[DataProvider('operationProvider')]
7475
public function testWithProvider(HttpOperation $operation, ?string $expectedProvider = null, ?string $expectedProcessor = null): void
7576
{
7677
if (!class_exists(DocumentManager::class)) {

src/Doctrine/Odm/Tests/PaginatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use ApiPlatform\Metadata\Exception\RuntimeException;
1919
use Doctrine\ODM\MongoDB\DocumentManager;
2020
use Doctrine\ODM\MongoDB\Iterator\Iterator;
21+
use PHPUnit\Framework\Attributes\DataProvider;
2122
use PHPUnit\Framework\Attributes\TestWith;
2223
use PHPUnit\Framework\TestCase;
2324
use Prophecy\PhpUnit\ProphecyTrait;
@@ -26,7 +27,7 @@ class PaginatorTest extends TestCase
2627
{
2728
use ProphecyTrait;
2829

29-
#[\PHPUnit\Framework\Attributes\DataProvider('initializeProvider')]
30+
#[DataProvider('initializeProvider')]
3031
public function testInitialize(int $firstResult, int $maxResults, int $totalItems, int $currentPage, int $lastPage, bool $hasNextPage): void
3132
{
3233
$paginator = $this->getPaginator($firstResult, $maxResults, $totalItems);

src/Doctrine/Odm/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Doctrine\Common\Collections\Collection;
2828
use Doctrine\ODM\MongoDB\DocumentManager;
2929
use Doctrine\ODM\MongoDB\Types\Type as MongoDbType;
30+
use PHPUnit\Framework\Attributes\DataProvider;
3031
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
3132
use PHPUnit\Framework\TestCase;
3233
use Symfony\Component\PropertyInfo\Type as LegacyType;
@@ -84,7 +85,7 @@ public function testTestGetPropertiesWithEmbedded(): void
8485
);
8586
}
8687

87-
#[\PHPUnit\Framework\Attributes\DataProvider('typesProvider')]
88+
#[DataProvider('typesProvider')]
8889
public function testExtract(string $property, ?Type $type): void
8990
{
9091
$this->assertEquals($type, $this->createExtractor()->getType(DoctrineDummy::class, $property));

0 commit comments

Comments
 (0)