Skip to content

Commit

Permalink
Merge fb6fe8b into 3557329
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Feb 20, 2021
2 parents 3557329 + fb6fe8b commit 4caf52a
Show file tree
Hide file tree
Showing 71 changed files with 1,005 additions and 123 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Expand Up @@ -384,7 +384,7 @@ jobs:
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction --tags '~@!lowest'

postgresql:
name: Behat (PHP ${{ matrix.php }}) (PostgreSQL)
Expand Down Expand Up @@ -599,7 +599,7 @@ jobs:
- '7.4'
fail-fast: false
env:
SYMFONY_DEPRECATIONS_HELPER: max[total]=8
SYMFONY_DEPRECATIONS_HELPER: max[total]=0
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -638,17 +638,19 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
symfony:
- '5.2'
- '5.3'
fail-fast: false
env:
SYMFONY_DEPRECATIONS_HELPER: max[direct]=0
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
Expand Down Expand Up @@ -698,17 +700,17 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
symfony:
- '5.2'
- '5.3'
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring
coverage: none
Expand All @@ -719,8 +721,7 @@ jobs:
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Allow unstable project dependencies
run: |
jq '. + {"minimum-stability": "dev"}' composer.json | sponge composer.json
run: composer config minimum-stability dev
- name: Cache dependencies
uses: actions/cache@v2
with:
Expand Down
15 changes: 13 additions & 2 deletions CHANGELOG.md
Expand Up @@ -9,7 +9,17 @@

## 2.6.3

* Identifiers: Re-allow `POST` operations even if no identifier is defined (#4052)
* Hydra: Fix partial pagination which no longer returns the `hydra:next` property (#4015)
* Security: Use a `NullToken` when using the new authenticator manager in the resource access checker (#4067)
* Mercure: Do not use data in options when deleting (#4056)
* Doctrine: Support for foreign identifiers (#4042)
* Doctrine: Support for binary UUID in search filter (#3774)
* JSON Schema: Allow generating documentation when property and method start from "is" (property `isActive` and method `isActive`) (#4064)
* OpenAPI: Fix missing 422 responses in the documentation (#4086)
* OpenAPI: Fix error when schema is empty (#4051)
* OpenAPI: Do not set scheme to oauth2 when generating securitySchemes (#4073)
* OpenAPI: Fix missing `$ref` when no `type` is used in context (#4076)

## 2.6.2

Expand Down Expand Up @@ -78,7 +88,7 @@
* Tests: adds a method to retrieve the CookieJar in the test Client `getCookieJar`
* Tests: Fix the registration of the `test.api_platform.client` service when the `FrameworkBundle` bundle is registered after the `ApiPlatformBundle` bundle (#3928)
* Validator: Add the violation code to the violation properties (#3857)
* Validator: Allow customizing the validation error status code (#3808)
* Validator: Allow customizing the validation error status code. **BC** Status code for validation errors is now 422, use `exception_to_status` to fallback to 400 if needed (#3808)
* Validator: Autoconfiguration of validation groups generator via `ApiPlatform\Core\Validator\ValidationGroupsGeneratorInterface`
* Validator: Deprecate using a validation groups generator service not implementing `ApiPlatform\Core\Bridge\Symfony\Validator\ValidationGroupsGeneratorInterface` (#3346)
* Validator: Property validation through OpenAPI (#33329)
Expand Down Expand Up @@ -235,7 +245,8 @@ For compatibility reasons with Symfony 5.2 and PHP 8, we do not test anymore the
## 2.5.0 beta 1

* Add an HTTP client dedicated to functional API testing (#2608)
* Add PATCH support (#2895)
* Add PATCH support (#2895)
Note: with JSON Merge Patch, responses will skip null values. As this may break on some endpoints, you need to manually [add the `merge-patch+json` format](https://api-platform.com/docs/core/content-negotiation/#configuring-patch-formats) to enable PATCH support. This will be the default behavior in API Platform 3.
* Add a command to generate json schemas `api:json-schema:generate` (#2996)
* Add infrastructure to generate a JSON Schema from a Resource `ApiPlatform\Core\JsonSchema\SchemaFactoryInterface` (#2983)
* Replaces `access_control` by `security` and adds a `security_post_denormalize` attribute (#2992)
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Expand Up @@ -50,7 +50,7 @@ postgres:
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
filters:
tags: '~@sqlite&&~@mongodb&&~@elasticsearch'
tags: '~@sqlite&&~@mongodb&&~@elasticsearch&&~@!postgres'

mongodb:
suites:
Expand Down
46 changes: 46 additions & 0 deletions features/doctrine/search_filter.feature
Expand Up @@ -539,6 +539,52 @@ Feature: Search filter on collections
}
"""

@!postgres
@!mongodb
@!lowest
Scenario: Search collection by binary UUID (Ramsey)
Given there is a ramsey identified resource with binary uuid "c19900a9-d2b2-45bf-b040-05c72d321282"
And there is a ramsey identified resource with binary uuid "a96cb2ed-e3dc-4449-9842-830e770cdecc"
When I send a "GET" request to "/ramsey_uuid_binary_dummies?id=c19900a9-d2b2-45bf-b040-05c72d321282"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to "1"

@!postgres
@!mongodb
@!lowest
Scenario: Search collection by binary UUID (Ramsey) (multiple values)
Given there is a ramsey identified resource with binary uuid "f71a6469-1bfc-4945-bad1-d6092f09a8c3"
When I send a "GET" request to "/ramsey_uuid_binary_dummies?id[]=c19900a9-d2b2-45bf-b040-05c72d321282&id[]=f71a6469-1bfc-4945-bad1-d6092f09a8c3"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to "2"

@!postgres
@!mongodb
@!lowest
Scenario: Search collection by related binary UUID (Ramsey)
Given there is a ramsey identified resource with binary uuid "56fa36c3-2b5e-4813-9e3a-b0bbe2ab5553" having a related resource with binary uuid "02227dc6-a371-4b8b-a34c-bbbf921b8ebd"
And there is a ramsey identified resource with binary uuid "4d796212-4b26-4e19-b092-a32d990b1e7e" having a related resource with binary uuid "31f64c33-6061-4fc1-b0e8-f4711b607c7d"
When I send a "GET" request to "/ramsey_uuid_binary_dummies?relateds=02227dc6-a371-4b8b-a34c-bbbf921b8ebd"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to "1"

@!postgres
@!mongodb
@!lowest
Scenario: Search collection by related binary UUID (Ramsey) (multiple values)
Given there is a ramsey identified resource with binary uuid "3248c908-a89d-483a-b75f-25888730d391" having a related resource with binary uuid "d7b2e909-37b0-411e-814c-74e044afbccb"
When I send a "GET" request to "/ramsey_uuid_binary_dummies?relateds[]=02227dc6-a371-4b8b-a34c-bbbf921b8ebd&relateds[]=d7b2e909-37b0-411e-814c-74e044afbccb"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to "2"

Scenario: Search for entities within an impossible range
When I send a "GET" request to "/dummies?name=MuYm"
Then the response status code should be 200
Expand Down
24 changes: 24 additions & 0 deletions features/main/overridden_operation.feature
Expand Up @@ -130,3 +130,27 @@ Feature: Create-Retrieve-Update-Delete with a Overridden Operation context
When I send a "DELETE" request to "/overridden_operation_dummies/1"
Then the response status code should be 204
And the response should be empty

@createSchema
Scenario: Use a POST operation to do a Remote Procedure Call without identifiers
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/rpc"
"""
{
"value": "Hello world"
}
"""
Then the response status code should be 202

@createSchema
Scenario: Use a POST operation to do a Remote Procedure Call without identifiers and with an output DTO
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/rpc_output"
"""
{
"value": "Hello world"
}
"""
Then the response status code should be 200
And the JSON node "success" should be equal to "YES"
And the JSON node "@type" should be equal to "RPC"
16 changes: 12 additions & 4 deletions features/openapi/docs.feature
Expand Up @@ -27,6 +27,7 @@ Feature: Documentation support
And the OpenAPI class "CustomNormalizedDummy-output" exists
And the OpenAPI class "CustomWritableIdentifierDummy" exists
And the OpenAPI class "Dummy" exists
And the OpenAPI class "DummyBoolean" exists
And the OpenAPI class "RelatedDummy" exists
And the OpenAPI class "DummyTableInheritance" exists
And the OpenAPI class "DummyTableInheritanceChild" exists
Expand All @@ -53,8 +54,11 @@ Feature: Documentation support
And the JSON node "paths./api/custom-call/{id}.get" should exist
And the JSON node "paths./api/custom-call/{id}.put" should exist
# Properties
And "id" property exists for the OpenAPI class "Dummy"
And "name" property is required for OpenAPI class "Dummy"
And the "id" property exists for the OpenAPI class "Dummy"
And the "name" property is required for the OpenAPI class "Dummy"
# Enable these tests when SF 4.4 / PHP 7.1 support is dropped
#And the "isDummyBoolean" property exists for the OpenAPI class "DummyBoolean"
#And the "isDummyBoolean" property is not read only for the OpenAPI class "DummyBoolean"
# Filters
And the JSON node "paths./dummies.get.parameters[3].name" should be equal to "dummyBoolean"
And the JSON node "paths./dummies.get.parameters[3].in" should be equal to "query"
Expand Down Expand Up @@ -129,6 +133,7 @@ Feature: Documentation support
And the Swagger class "CustomNormalizedDummy-output" exists
And the Swagger class "CustomWritableIdentifierDummy" exists
And the Swagger class "Dummy" exists
And the Swagger class "DummyBoolean" exists
And the Swagger class "RelatedDummy" exists
And the Swagger class "DummyTableInheritance" exists
And the Swagger class "DummyTableInheritanceChild" exists
Expand All @@ -155,8 +160,11 @@ Feature: Documentation support
And the JSON node "paths./api/custom-call/{id}.get" should exist
And the JSON node "paths./api/custom-call/{id}.put" should exist
# Properties
And "id" property exists for the Swagger class "Dummy"
And "name" property is required for Swagger class "Dummy"
And the "id" property exists for the Swagger class "Dummy"
And the "name" property is required for the Swagger class "Dummy"
# Enable these tests when SF 4.4 / PHP 7.1 support is dropped
#And the "isDummyBoolean" property exists for the Swagger class "DummyBoolean"
#And the "isDummyBoolean" property is not read only for the Swagger class "DummyBoolean"
# Filters
And the JSON node "paths./dummies.get.parameters[0].name" should be equal to "dummyBoolean"
And the JSON node "paths./dummies.get.parameters[0].in" should be equal to "query"
Expand Down
4 changes: 2 additions & 2 deletions features/security/strong_typing.feature
Expand Up @@ -33,8 +33,8 @@ Feature: Handle properly invalid data submitted to the API
"jsonData": [],
"arrayData": [],
"name_converted": null,
"relatedOwnedDummy": null,
"relatedOwningDummy": null,
"relatedOwnedDummy": null,
"relatedOwningDummy": null,
"id": 1,
"name": "Not existing",
"alias": null,
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Expand Up @@ -89,6 +89,9 @@ parameters:
message: '#Property Doctrine\\ORM\\Mapping\\ClassMetadataInfo::\$fieldMappings \(array.*\)>\) does not accept array\(.*\)\.#'
path: tests/Bridge/Doctrine/Orm/Metadata/Property/DoctrineOrmPropertyMetadataFactoryTest.php

# Expected, Symfony 5.3
- '#getCollectionValueT|getCollectionKeyTyp#'

# Expected, due to PHP 8 attributes
- '#ReflectionProperty::getAttributes\(\)#'
- '#ReflectionMethod::getAttributes\(\)#'
Expand Down
2 changes: 1 addition & 1 deletion src/Api/IdentifiersExtractor.php
Expand Up @@ -62,7 +62,7 @@ public function getIdentifiersFromResourceClass(string $resourceClass): array
return ['id'];
}

throw new RuntimeException(sprintf('No identifier defined "%s". You should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]" on the property identifying the resource."', $resourceClass));
throw new RuntimeException(sprintf('No identifier defined in "%s". You should add #[\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]" on the property identifying the resource."', $resourceClass));
}

return $identifiers;
Expand Down
12 changes: 10 additions & 2 deletions src/Bridge/Doctrine/Orm/Extension/FilterEagerLoadingExtension.php
Expand Up @@ -76,8 +76,16 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
if (!$classMetadata->isIdentifierComposite) {
$replacementAlias = $queryNameGenerator->generateJoinAlias($originAlias);
$in = $this->getQueryBuilderWithNewAliases($queryBuilder, $queryNameGenerator, $originAlias, $replacementAlias);
$in->select($replacementAlias);
$queryBuilderClone->andWhere($queryBuilderClone->expr()->in($originAlias, $in->getDQL()));

if ($classMetadata->containsForeignIdentifier) {
$identifier = current($classMetadata->getIdentifier());
$in->select("IDENTITY($replacementAlias.$identifier)");
$queryBuilderClone->andWhere($queryBuilderClone->expr()->in("$originAlias.$identifier", $in->getDQL()));
} else {
$in->select($replacementAlias);
$queryBuilderClone->andWhere($queryBuilderClone->expr()->in($originAlias, $in->getDQL()));
}

$changedWhereClause = true;
} else {
// Because Doctrine doesn't support WHERE ( foo, bar ) IN () (https://github.com/doctrine/doctrine2/issues/5238), we are building as many subqueries as they are identifiers
Expand Down
5 changes: 5 additions & 0 deletions src/Bridge/Doctrine/Orm/Extension/OrderExtension.php
Expand Up @@ -80,6 +80,11 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
}

if (null !== $this->order) {
// A foreign identifier cannot be used for ordering.
if ($classMetaData->containsForeignIdentifier) {
return;
}

foreach ($identifiers as $identifier) {
$queryBuilder->addOrderBy("{$rootAlias}.{$identifier}", $this->order);
}
Expand Down

0 comments on commit 4caf52a

Please sign in to comment.