Skip to content

Commit a5e0616

Browse files
authored
Merge pull request #5250 from alanpoulain/chore/merge-3.0
Merge 3.0
2 parents 87e64e1 + 7670df1 commit a5e0616

File tree

7 files changed

+80
-22
lines changed

7 files changed

+80
-22
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,15 @@ jobs:
397397
steps:
398398
- name: Checkout
399399
uses: actions/checkout@v3
400-
- name: Check
400+
- name: Setup MongoDB
401401
run: |
402-
sudo systemctl start mongod.service
402+
sudo apt update
403+
sudo apt install -y wget gnupg
404+
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
405+
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
406+
sudo apt update
407+
sudo apt install -y mongodb-org
408+
sudo systemctl start mongod
403409
- name: Setup PHP
404410
uses: shivammathur/setup-php@v2
405411
with:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v3.0.6
4+
5+
### Bug fixes
6+
7+
* [d4173e7db](https://github.com/api-platform/core/commit/d4173e7dbca8e72af484c38fa0dc46a81b238fc6) fix(metadata): do not override name fixes #5235 (#5237)
8+
39
## v3.0.5
410

511
### Bug fixes
@@ -97,6 +103,7 @@ Breaking changes:
97103
* Identifiers: using an object as identifier is supported only when this object is `Stringable`
98104
* Serializer: `skip_null_values` now defaults to `true`
99105
* Metadata: `Patch` is added to the automatic CRUD
106+
* Symfony: generated route names and operation names changed, route naming can be changed directly within metadata
100107

101108
## v2.7.5
102109

src/Metadata/Resource/Factory/OperationDefaultsTrait.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,6 @@ private function getOperationWithDefaults(ApiResource $resource, Operation $oper
187187
$operation = $operation->withName($operation->getRouteName());
188188
}
189189

190-
// Check for name conflict
191-
if ($operation->getName() && null !== ($operations = $resource->getOperations())) {
192-
if (!$operations->has($operation->getName())) {
193-
return [$operation->getName(), $operation];
194-
}
195-
196-
$this->logger->warning(sprintf('The operation "%s" already exists on the resource "%s", pick a different name or leave it empty. In the meantime we will generate a unique name.', $operation->getName(), $resource->getClass()));
197-
/** @var HttpOperation $operation */
198-
$operation = $operation->withName('');
199-
}
200-
201190
$operationName = $operation->getName() ?? sprintf(
202191
'_api_%s_%s%s',
203192
$operation->getUriTemplate() ?: $operation->getShortName(),

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use phpDocumentor\Reflection\DocBlockFactoryInterface;
4040
use PHPStan\PhpDocParser\Parser\PhpDocParser;
4141
use Ramsey\Uuid\Uuid;
42-
use Symfony\Component\Cache\Adapter\ArrayAdapter;
4342
use Symfony\Component\Config\FileLocator;
4443
use Symfony\Component\Config\Resource\DirectoryResource;
4544
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -535,14 +534,7 @@ private function registerGraphQlConfiguration(ContainerBuilder $container, array
535534

536535
private function registerCacheConfiguration(ContainerBuilder $container): void
537536
{
538-
if ($container->hasParameter('kernel.debug') && $container->getParameter('kernel.debug')) {
539-
$container->register('api_platform.cache.metadata.property', ArrayAdapter::class)->addTag('cache.pool');
540-
$container->register('api_platform.cache.metadata.resource', ArrayAdapter::class)->addTag('cache.pool');
541-
$container->register('api_platform.cache.metadata.resource_collection', ArrayAdapter::class)->addTag('cache.pool');
542-
$container->register('api_platform.cache.route_name_resolver', ArrayAdapter::class)->addTag('cache.pool');
543-
$container->register('api_platform.cache.identifiers_extractor', ArrayAdapter::class);
544-
$container->register('api_platform.elasticsearch.cache.metadata.document', ArrayAdapter::class);
545-
} else {
537+
if (!$container->hasParameter('kernel.debug') || !$container->getParameter('kernel.debug')) {
546538
$container->removeDefinition('api_platform.cache_warmer.cache_pool_clearer');
547539
}
548540
}

src/Symfony/Bundle/Resources/config/jsonld.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
<service id="api_platform.jsonld.encoder" class="ApiPlatform\Serializer\JsonEncoder" public="false">
4747
<argument>jsonld</argument>
48+
<argument type="service" id="serializer.json.encoder" on-invalid="null" />
4849

4950
<tag name="serializer.encoder" />
5051
</service>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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\Tests\Fixtures\TestBundle\ApiResource;
15+
16+
use ApiPlatform\Metadata\ApiProperty;
17+
use ApiPlatform\Metadata\ApiResource;
18+
use ApiPlatform\Metadata\Get;
19+
use ApiPlatform\Metadata\Post;
20+
21+
#[
22+
ApiResource(
23+
shortName: 'PasswordResource',
24+
operations: [
25+
new Post(
26+
uriTemplate: '/password/reset',
27+
name: 'password_reset',
28+
),
29+
new Post(
30+
uriTemplate: '/password/set',
31+
name: 'password_set',
32+
),
33+
new Get(
34+
uriTemplate: '/password/reset/{token}',
35+
name: 'password_reset_token',
36+
),
37+
],
38+
routePrefix: '/users'
39+
)
40+
]
41+
/**
42+
* Test for issue #5235.
43+
*/
44+
class PasswordResource
45+
{
46+
#[ApiProperty(identifier: true)]
47+
public ?string $token = null;
48+
}

tests/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactoryTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use ApiPlatform\Metadata\Put;
2828
use ApiPlatform\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory;
2929
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
30+
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\PasswordResource;
3031
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\AttributeDefaultOperations;
3132
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\AttributeOnlyOperation;
3233
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\AttributeResource;
@@ -226,4 +227,18 @@ class: AttributeOnlyOperation::class,
226227
),
227228
]), $attributeResourceMetadataCollectionFactory->create(AttributeOnlyOperation::class));
228229
}
230+
231+
/**
232+
* Tests issue #5235.
233+
*/
234+
public function testNameDeclarationShouldNotBeRemoved(): void
235+
{
236+
$attributeResourceMetadataCollectionFactory = new AttributesResourceMetadataCollectionFactory();
237+
238+
$metadataCollection = $attributeResourceMetadataCollectionFactory->create(PasswordResource::class);
239+
$operations = $metadataCollection[0]->getOperations();
240+
$this->assertTrue($operations->has('password_set'));
241+
$this->assertTrue($operations->has('password_reset_token'));
242+
$this->assertTrue($operations->has('password_reset'));
243+
}
229244
}

0 commit comments

Comments
 (0)