Skip to content

Commit 81a0f85

Browse files
committed
Merge 4.0
2 parents de3bed2 + b4e5494 commit 81a0f85

File tree

25 files changed

+235
-104
lines changed

25 files changed

+235
-104
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
]);
3030

3131
return (new PhpCsFixer\Config())
32+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
3233
->setRiskyAllowed(true)
3334
->setRules([
3435
'@DoctrineAnnotation' => true,

CHANGELOG.md

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

3+
## v4.0.11
4+
5+
### Bug fixes
6+
7+
* [af66075fd](https://github.com/api-platform/core/commit/af66075fdd6b83bdebc1c4ca33cc0ab7e1a7f8af) fix(laravel): fix foregin keys (relations) beeing in attributes (#6843)
8+
9+
10+
### Features
11+
12+
* [2d59c6369](https://github.com/api-platform/core/commit/2d59c63699b4602cfe4d62504896c6d4121c1be4) feat(laravel): belongs to many relations (#6818)
13+
14+
Also contains [v3.4.8 changes](#v348).
15+
316
## v4.0.10
417

518
### Bug fixes
@@ -211,6 +224,16 @@ Notes:
211224

212225
* [0d5f35683](https://github.com/api-platform/core/commit/0d5f356839eb6aa9f536044abe4affa736553e76) feat(laravel): laravel component (#5882)
213226

227+
## v3.4.8
228+
229+
### Bug fixes
230+
231+
* [4d7deeaf7](https://github.com/api-platform/core/commit/4d7deeaf794178b5496ae989520095831a86df8a) fix(jsonld): check if supportedTypes exists (#6825)
232+
* [5111935d4](https://github.com/api-platform/core/commit/5111935d4f917920c6f3d24b828f9d59fd0e3520) fix(symfony): object typed property schema collection restriction (#6823)
233+
* [6bf894f6f](https://github.com/api-platform/core/commit/6bf894f6f0ead0751936aeddcfc527f017498bb3) fix(serializer): use attribute denormalization context for constructor arguments (#6821)
234+
* [86c97cac3](https://github.com/api-platform/core/commit/86c97cac3b8d45b6190e2999b99a02e88dd4e527) fix(symfony): symfony 7.2 deprecations (#6835)
235+
* [d312eae7e](https://github.com/api-platform/core/commit/d312eae7ef590ec05139c09bfaf2d3c7668a3f22) fix(doctrine): fixed orm datefilter applying inner join when no filtering values have been provided (#6849)
236+
214237
## v3.4.7
215238

216239
### Bug fixes

features/security/strong_typing.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ Feature: Handle properly invalid data submitted to the API
8989
And the response should be in JSON
9090
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
9191

92+
Scenario: Ignore date with wrong format
93+
When I add "Content-Type" header equal to "application/ld+json"
94+
And I send a "POST" request to "/dummies" with body:
95+
"""
96+
{
97+
"name": "Invalid date format",
98+
"dummyDateWithFormat": "2020-01-01T00:00:00+00:00"
99+
}
100+
"""
101+
Then the response status code should be 400
102+
And the response should be in JSON
103+
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
104+
92105
Scenario: Send non-array data when an array is expected
93106
When I add "Content-Type" header equal to "application/ld+json"
94107
And I send a "POST" request to "/dummies" with body:

src/Doctrine/Orm/Filter/DateFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected function filterProperty(string $property, $values, QueryBuilder $query
153153
$alias = $queryBuilder->getRootAliases()[0];
154154
$field = $property;
155155

156-
if ($this->isPropertyNested($property, $resourceClass)) {
156+
if ($this->isPropertyNested($property, $resourceClass) && \count($values) > 0) {
157157
[$alias, $field] = $this->addJoinsForNestedProperty($property, $alias, $queryBuilder, $queryNameGenerator, $resourceClass, Join::INNER_JOIN);
158158
}
159159

src/Elasticsearch/Serializer/NameConverter/InnerFieldsNameConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @author Baptiste Meyer <[email protected]>
2626
*/
27-
final class InnerFieldsNameConverter implements AdvancedNameConverterInterface
27+
final class InnerFieldsNameConverter implements NameConverterInterface, AdvancedNameConverterInterface
2828
{
2929
public function __construct(private readonly NameConverterInterface $inner = new CamelCaseToSnakeCaseNameConverter())
3030
{

src/JsonApi/Serializer/ReservedAttributeNameConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @author Baptiste Meyer <[email protected]>
2424
*/
25-
final class ReservedAttributeNameConverter implements AdvancedNameConverterInterface
25+
final class ReservedAttributeNameConverter implements NameConverterInterface, AdvancedNameConverterInterface
2626
{
2727
public const JSON_API_RESERVED_ATTRIBUTES = [
2828
'id' => '_id',

src/JsonLd/Serializer/ErrorNormalizer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
5757

5858
public function getSupportedTypes(?string $format): array
5959
{
60-
return $this->inner->getSupportedTypes($format);
60+
if (method_exists($this->inner, 'getSupportedTypes')) {
61+
return $this->inner->getSupportedTypes($format);
62+
}
63+
64+
return [];
6165
}
6266
}

src/Laravel/ApiPlatformMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
}
2727

2828
/**
29-
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
29+
* @param \Closure(Request): (Response) $next
3030
*/
3131
public function handle(Request $request, \Closure $next, ?string $operationName = null): Response
3232
{

src/Laravel/Eloquent/Metadata/ModelMetadata.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ public function getAttributes(Model $model): Collection
6767
$table = $model->getTable();
6868
$columns = $schema->getColumns($table);
6969
$indexes = $schema->getIndexes($table);
70+
$relations = $this->getRelations($model);
7071

7172
return collect($columns)
73+
->reject(
74+
fn ($column) => $relations->contains(
75+
fn ($relation) => $relation['foreign_key'] === $column['name']
76+
)
77+
)
7278
->map(fn ($column) => [
7379
'name' => $column['name'],
7480
'type' => $column['type'],

src/Laravel/Eloquent/State/CollectionProvider.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
5858
$query = $extension->apply($query, $uriVariables, $operation, $context);
5959
}
6060

61+
if ($order = $operation->getOrder()) {
62+
$isList = array_is_list($order);
63+
foreach ($order as $property => $direction) {
64+
if ($isList) {
65+
$property = $direction;
66+
$direction = 'ASC';
67+
}
68+
69+
if (str_contains($property, '.')) {
70+
[$table, $property] = explode('.', $property);
71+
72+
// Relation Order by, we need to do laravel eager loading
73+
$query->with([
74+
$table => fn ($query) => $query->orderBy($property, $direction),
75+
]);
76+
77+
continue;
78+
}
79+
80+
$query->orderBy($property, $direction);
81+
}
82+
}
83+
6184
if (false === $this->pagination->isEnabled($operation, $context)) {
6285
return $query->get();
6386
}

0 commit comments

Comments
 (0)