Skip to content

Commit 272b7c9

Browse files
committed
Merge 4.1
2 parents f48a2be + c12d3dc commit 272b7c9

File tree

60 files changed

+661
-94
lines changed

Some content is hidden

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

60 files changed

+661
-94
lines changed

.github/patches/phpunit.patch

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
diff --git a/src/Runner/ErrorHandler.php b/src/Runner/ErrorHandler.php
2+
index 54f35aa41..94a2bb600 100644
3+
--- a/src/Runner/ErrorHandler.php
4+
+++ b/src/Runner/ErrorHandler.php
5+
@@ -59,6 +59,11 @@ final class ErrorHandler
6+
private ?int $originalErrorReportingLevel = null;
7+
private readonly Source $source;
8+
9+
+ /**
10+
+ * @var list<array{int, string, string, int}>
11+
+ */
12+
+ private array $globalDeprecations = [];
13+
+
14+
/**
15+
* @var ?array{functions: list<non-empty-string>, methods: list<array{className: class-string, methodName: non-empty-string}>}
16+
*/
17+
@@ -197,6 +202,23 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil
18+
return false;
19+
}
20+
21+
+ public function deprecationHandler(int $errorNumber, string $errorString, string $errorFile, int $errorLine): bool
22+
+ {
23+
+ $this->globalDeprecations[] = [$errorNumber, $errorString, $errorFile, $errorLine];
24+
+
25+
+ return true;
26+
+ }
27+
+
28+
+ public function registerDeprecationHandler(): void
29+
+ {
30+
+ set_error_handler([self::$instance, 'deprecationHandler'], E_USER_DEPRECATED);
31+
+ }
32+
+
33+
+ public function restoreDeprecationHandler(): void
34+
+ {
35+
+ restore_error_handler();
36+
+ }
37+
+
38+
public function enable(): void
39+
{
40+
if ($this->enabled) {
41+
@@ -213,6 +235,7 @@ public function enable(): void
42+
43+
$this->enabled = true;
44+
$this->originalErrorReportingLevel = error_reporting();
45+
+ $this->triggerGlobalDeprecations();
46+
47+
error_reporting($this->originalErrorReportingLevel & self::UNHANDLEABLE_LEVELS);
48+
}
49+
@@ -422,4 +445,11 @@ private function stackTrace(): string
50+
51+
return $buffer;
52+
}
53+
+
54+
+ private function triggerGlobalDeprecations(): void
55+
+ {
56+
+ foreach ($this->globalDeprecations ?? [] as $d) {
57+
+ $this->__invoke(...$d);
58+
+ }
59+
+ }
60+
}
61+
diff --git a/src/TextUI/Application.php b/src/TextUI/Application.php
62+
index ca6da7005..d8965d41b 100644
63+
--- a/src/TextUI/Application.php
64+
+++ b/src/TextUI/Application.php
65+
@@ -178,8 +178,12 @@ public function run(array $argv): int
66+
67+
EventFacade::instance()->seal();
68+
69+
+ ErrorHandler::instance()->registerDeprecationHandler();
70+
+
71+
$testSuite = $this->buildTestSuite($configuration);
72+
73+
+ ErrorHandler::instance()->restoreDeprecationHandler();
74+
+
75+
$this->executeCommandsThatRequireTheTestSuite($configuration, $cliConfiguration, $testSuite);
76+
77+
if ($testSuite->isEmpty() && !$configuration->hasCliArguments() && $configuration->testSuite()->isEmpty()) {

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,8 @@ jobs:
862862
composer global link .
863863
- name: Clear test app cache
864864
run: tests/Fixtures/app/console cache:clear --ansi
865+
- name: Patch phpunit
866+
run: git apply --directory vendor/phpunit/phpunit .github/patches/phpunit.patch
865867
- name: Run PHPUnit tests
866868
run: vendor/bin/phpunit --fail-on-deprecation --display-deprecations
867869

@@ -906,7 +908,7 @@ jobs:
906908
- name: Clear test app cache
907909
run: tests/Fixtures/app/console cache:clear --ansi
908910
- name: Run PHPUnit tests
909-
run: vendor/bin/phpunit
911+
run: vendor/bin/phpunit --fail-on-deprecation
910912

911913
behat-symfony-next:
912914
name: Behat (PHP ${{ matrix.php }}) (Symfony dev)

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
# Changelog
22

3+
## v4.1.7
4+
5+
### Bug fixes
6+
7+
* [40c09d1c0](https://github.com/api-platform/core/commit/40c09d1c0560ec5c2a96391faf9fbe328f6f2f97) fix(metadata): yaml link security (#7066)
8+
* [545eb69b8](https://github.com/api-platform/core/commit/545eb69b86797f436b8c494912513e1ef9064550) fix(symfony): internal resources should not inherit global defaults (#7073)
9+
* [615bdd6b1](https://github.com/api-platform/core/commit/615bdd6b1c372f6438c6460dfcce69ef6c746e08) fix(hydra): use correctly enable_docs (#7062)
10+
* [694681f4b](https://github.com/api-platform/core/commit/694681f4b187688dd41de1912637003a2fb313a2) fix(symfony): do not ignore Test files on symfony (#7077)
11+
* [6f15be5c7](https://github.com/api-platform/core/commit/6f15be5c7badf197f10bb7d57dd79373f855ef20) fix(laravel): eloquent BelongsTo linking (#7075)
12+
* [dddd3eee4](https://github.com/api-platform/core/commit/dddd3eee40af2e8126476ce3fe4c69f33ec15ac0) fix(metadata): parameter provider within filter (#7081)
13+
* [dfca9bf60](https://github.com/api-platform/core/commit/dfca9bf6023c5535ce7ee9b3829a8efd7f1f9398) Revert "fix(jsonld): duplicate error fields when prefix is enabled (#7021)" (#7074)
14+
* [d696a8e42](https://github.com/api-platform/core/commit/d696a8e4284b0e5b5c56300852bab70283386a99) fix(metadata): use template typehint in parameters (#7078)
15+
316
## v4.1.6
417

518
### Bug fixes
619

720
* [44e560839](https://github.com/api-platform/core/commit/44e56083996f2f00a1d87a149fd41aeb0149e4dd) fix(laravel): undefined variable app
821

9-
### Features
10-
1122
## v4.1.5
1223

1324
### Bug fixes

features/hydra/collection.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ Feature: Collections support
479479

480480
When I send a "GET" request to "/dummies?itemsPerPage=0&page=2"
481481
Then the response status code should be 400
482-
And the JSON node "detail" should be equal to "Page should not be greater than 1 if limit is equal to 0"
482+
And the JSON node "description" should be equal to "Page should not be greater than 1 if limit is equal to 0"
483483

484484
Scenario: Cursor-based pagination with an empty collection
485485
When I send a "GET" request to "/so_manies"

features/hydra/error.feature

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Feature: Error handling
1616
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
1717
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
1818
And the JSON node "type" should exist
19-
And the JSON node "title" should not exists
19+
And the JSON node "title" should be equal to "An error occurred"
2020
And the JSON node "hydra:title" should be equal to "An error occurred"
2121
And the JSON node "detail" should exist
22-
And the JSON node "description" should not exist
22+
And the JSON node "description" should exist
2323
And the JSON node "hydra:description" should exist
2424
And the JSON node "trace" should exist
2525
And the JSON node "status" should exist
@@ -49,8 +49,10 @@ Feature: Error handling
4949
}
5050
],
5151
"detail": "name: This value should not be blank.",
52+
"title": "An error occurred",
5253
"hydra:title": "An error occurred",
5354
"hydra:description": "name: This value should not be blank.",
55+
"description": "name: This value should not be blank.",
5456
"type": "/validation_errors/c1051bb4-d103-4f74-8988-acbcafc7fdc3"
5557
}
5658
"""
@@ -67,7 +69,7 @@ Feature: Error handling
6769
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
6870
And the JSON node "@context" should exist
6971
And the JSON node "type" should exist
70-
And the JSON node "hydra:title" should be equal to "An error occurred"
72+
And the JSON node "title" should be equal to "An error occurred"
7173
And the JSON node "detail" should exist
7274

7375
Scenario: Get an rfc 7807 not found error
@@ -82,9 +84,9 @@ Feature: Error handling
8284
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
8385
And the JSON node "@context" should exist
8486
And the JSON node "type" should exist
85-
And the JSON node "hydra:title" should be equal to "An error occurred"
87+
And the JSON node "title" should be equal to "An error occurred"
8688
And the JSON node "detail" should exist
87-
And the JSON node "description" should not exist
89+
And the JSON node "description" should exist
8890

8991
Scenario: Get an rfc 7807 bad method error
9092
When I add "Content-Type" header equal to "application/ld+json"
@@ -99,9 +101,9 @@ Feature: Error handling
99101
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
100102
And the JSON node "@context" should exist
101103
And the JSON node "type" should exist
102-
And the JSON node "hydra:title" should be equal to "An error occurred"
104+
And the JSON node "title" should be equal to "An error occurred"
103105
And the JSON node "detail" should exist
104-
And the JSON node "description" should not exist
106+
And the JSON node "description" should exist
105107

106108
Scenario: Get an rfc 7807 validation error
107109
When I add "Content-Type" header equal to "application/ld+json"
@@ -116,7 +118,7 @@ Feature: Error handling
116118
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
117119
And the JSON node "@context" should exist
118120
And the JSON node "type" should exist
119-
And the JSON node "hydra:title" should be equal to "An error occurred"
121+
And the JSON node "title" should be equal to "An error occurred"
120122
And the JSON node "detail" should exist
121123
And the JSON node "violations" should exist
122124

@@ -131,8 +133,8 @@ Feature: Error handling
131133
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
132134
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
133135
And the JSON node "type" should exist
134-
And the JSON node "hydra:title" should be equal to "An error occurred"
136+
And the JSON node "title" should be equal to "An error occurred"
135137
And the JSON node "detail" should exist
136-
And the JSON node "description" should not exist
138+
And the JSON node "description" should exist
137139
And the JSON node "trace" should exist
138140
And the JSON node "status" should exist

features/jsonld/input_output.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ Feature: JSON-LD DTO input and output
309309
"""
310310
Then the response status code should be 400
311311
And the response should be in JSON
312-
And the JSON node "detail" should be equal to "The input data is misformatted."
312+
And the JSON node "description" should be equal to "The input data is misformatted."
313313

314314
@!mongodb
315315
Scenario: Reset password through an input DTO without DataTransformer

features/main/attribute_resource.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Feature: Resource attributes
100100
And the response should be in JSON
101101
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
102102
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
103-
And the JSON node "detail" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"'
103+
And the JSON node "description" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"'
104104

105105
Scenario: Uri variables with Post operation
106106
When I add "Content-Type" header equal to "application/ld+json"

features/main/crud.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Feature: Create-Retrieve-Update-Delete
9696
When I add "Content-Type" header equal to "application/ld+json"
9797
And I send a "POST" request to "/dummies"
9898
Then the response status code should be 400
99-
And the JSON node "detail" should be equal to "Syntax error"
99+
And the JSON node "description" should be equal to "Syntax error"
100100

101101
Scenario: Get a not found exception
102102
When I send a "GET" request to "/dummies/42"
@@ -554,7 +554,7 @@ Feature: Create-Retrieve-Update-Delete
554554
When I add "Content-Type" header equal to "application/ld+json"
555555
And I send a "PUT" request to "/dummies/1"
556556
Then the response status code should be 400
557-
And the JSON node "detail" should be equal to "Syntax error"
557+
And the JSON node "description" should be equal to "Syntax error"
558558

559559
Scenario: Delete a resource
560560
When I send a "DELETE" request to "/dummies/1"

features/main/not_exposed.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Feature: Expose only a collection of objects
171171
When I send a "GET" request to "<uri>"
172172
Then the response status code should be 404
173173
And the response should be in JSON
174-
And the JSON node "detail" should be equal to "<description>"
174+
And the JSON node "description" should be equal to "<description>"
175175
Examples:
176176
| uri | description |
177177
| /tables/12345 | This route does not aim to be called. |
@@ -181,7 +181,7 @@ Feature: Expose only a collection of objects
181181
When I send a "GET" request to "<uri>"
182182
Then the response status code should be 404
183183
And the response should be in JSON
184-
And the JSON node "detail" should be equal to "<description>"
184+
And the JSON node "description" should be equal to "<description>"
185185
Examples:
186186
| uri | description |
187187
| /.well-known/genid/12345 | This route is not exposed on purpose. It generates an IRI for a collection resource without identifier nor item operation. |

features/main/relation.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ Feature: Relations support
472472
Then the response status code should be 400
473473
And the response should be in JSON
474474
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
475-
And the JSON node "detail" should contain 'Invalid IRI "certainly not an IRI".'
475+
And the JSON node "description" should contain 'Invalid IRI "certainly not an IRI".'
476476

477477
Scenario: Passing an invalid type to a relation
478478
When I add "Content-Type" header equal to "application/ld+json"
@@ -495,18 +495,18 @@ Feature: Relations support
495495
"type": "string",
496496
"pattern": "^hydra:Error$"
497497
},
498-
"hydra:title": {
498+
"title": {
499499
"type": "string",
500500
"pattern": "^An error occurred$"
501501
},
502-
"detail": {
502+
"description": {
503503
"pattern": "^The type of the \"ApiPlatform\\\\Tests\\\\Fixtures\\\\TestBundle\\\\(Document|Entity)\\\\RelatedDummy\" resource must be \"array\" \\(nested document\\) or \"string\" \\(IRI\\), \"integer\" given.$"
504504
}
505505
},
506506
"required": [
507507
"@type",
508-
"hydra:title",
509-
"detail"
508+
"title",
509+
"description"
510510
]
511511
}
512512
"""

0 commit comments

Comments
 (0)