This PR was merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] Add conflict rules for incompatible ext-psr versions
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | N/A
| License | MIT
| Doc PR | N/A
This PR adds conflict rules for outdated versions of the PECL extension `psr` which are known to cause compatibility issues with DependencyInjection 5.3 and ServiceContracts 2.4.
Commits
-------
a02f062149 [DependencyInjection] Add conflict rules for incompatible ext-psr versions
This PR was merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] Add `#[Target]` to tell how a dependency is used and hint named autowiring aliases
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Right now, when one wants to target a specific service in a list of candidates, we rely on the name of the argument in addition to the type-hint, eg:
`function foo(WorkflowInterface $reviewStateMachine)`
The deal is that by giving the argument a name that matches the target use case of the required dependency, we make autowiring more useful.
But sometimes, being able to de-correlate the name of the argument and the purpose is desired.
This PR introduces a new `#[Target]` attribute on PHP8 that allows doing so. The previous example could be written as such thanks to it:
`function foo(#[Target('review.state_machine')] WorkflowInterface $workflow)`
That's all folks :)
Commits
-------
cc76eab795 [DependencyInjection] Add `#[Target]` to tell how a dependency is used and hint named autowiring aliases
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Config] Support extensions without configuration in ConfigBuilder warmup
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
`ConfigurationExtensionInterface::getConfiguration()` is nullable.
As a real use-case: A small internal bundle in my company just uses `array_merge` to manage a very limited set of configuration. We don't have these fancy Configuration classes.
Commits
-------
0a6f5e50b7 [Config] Support extensions without configuration
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Notifier] Add missing entries in scheme to package map
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | - <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- Never break backward compatibility (see https://symfony.com/bc).
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too.)
- Features and deprecations must be submitted against branch 5.x.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
-->
Commits
-------
8cf605062b Add missing entries in scheme to package map
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Notifier] Notifier add test for adding transport factories to framework extension
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | <!-- required for new features -->
Follow up of https://github.com/symfony/symfony/pull/40843 and https://github.com/symfony/symfony/pull/40844
Needs to be rebased after both were merged.
See changes: ddf61c2dae
Commits
-------
3118c9088a Make sure we will not forget to add notifier transport factories to FrameworkExtension anymore
This PR was merged into the 5.3-dev branch.
Discussion
----------
[SecurityBundle] Deprecate public services to private
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | yes
| Tickets | -
| License | MIT
| Doc PR | -
Follow up of https://github.com/symfony/symfony/pull/36691 on the SecurityBundle
Commits
-------
56be86aa7d [SecurityBundle] Deprecate public services to private
This PR was merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle][Notifier] Fix wrong class name usage
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | - <!-- required for new features -->
I got the following error message a new symfony installation while trying to require fake-sms and fake-chat:
```
symfony new --version=next --dir=new
cd new
composer req notifier
composer req symfony/fake-chat-notifier
```
```
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In ContainerBuilder.php line 994:
!!
!! You have requested a non-existent service "notifier.transport_factory.fakechat".
!!
!!
!!
Script `@auto`-scripts was called via post-update-cmd
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
```
Commits
-------
213ef7f39f Fix wrong class name usage
This PR was merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle] Add basic tests for the notifier framework bundle integration
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | <!-- required for new features -->
This PR adds basic tests for the notifier framework bundle integration:
- [x] Adjust the symfony-1.0.xsd and define the notifier type
- [x] Add general notifier configuration tests in FrameworkExtensionTest
Commits
-------
47088eb53a Add basic notifier tests
This PR was merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] Add `#[When(env: 'foo')]` to skip autoregistering a class when the env doesn't match
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This is a follow up of #40214, in order to conditionally auto-register classes.
By adding a `#[When(env: prod)]` annotation on a class, one can tell that a class should be skipped when the current env doesn't match the one declared in the attribute.
This saves from writing similar conditional configuration by using the per-env `services_prod.yaml` convention (+corresponding exclusion from `services.yaml`), or some logic in the Kernel.
Commits
-------
59c75bad7b [DI] add `#[When(env: 'foo')]` to skip autoregistering a class when the env doesn't match
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle] Add missing notifier transport factories to framework extension
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | <!-- required for new features -->
Tests on https://github.com/symfony/symfony/pull/39353 were failing (https://travis-ci.com/github/symfony/symfony/jobs/499236540) because of missing entries in the `$classToServices` array. They are now added and the list is ordered alphabetically.
Missing entries:
- LightSmsTransportFactory
- SmsBiurasTransportFactory
- MessageBirdTransport
Commits
-------
a83c9fe79a [FrameworkBundle] Add missing notifier transport factories to framework extension
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Security] Add passport to AuthenticationTokenCreatedEvent
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
This is a follow-up to my previous PR #37359, which added `AuthenticationTokenCreatedEvent` to the new authenticator-based security system to inspect the security token before it becomes effective to the security system. It **adds the passport** that was used to generate that token to the event, so that it can be inspected as well.
Reasoning:
1) It makes the event more aligned with other security events (which are also providing the passport)
2) I see valid use-cases when you'd want to look into the passport/badges to decide if you'd want to make modifications to the security token. @seldaek mentioned to me in scheb/2fa#74 that he'd like to have the ability to add a badge from his custom authenticator class, which then influences 2fa being triggered or not. Having the passport in the event would make that a straight forward task.
I would like to add this to Symfony 5.3, since @wouterj plans to stabilize the authenticator security system for that release, so I believe this is worth adding it now rather than later. The constructor change could be considered a BC break, but since authenticator system is experimental, I believe it's fair to make that change now before declaring it "stable".
Commits
-------
74196e0750 Add passport to AuthenticationTokenCreatedEvent
This PR was submitted for the 5.x branch but it was squashed and merged into the 4.4 branch instead.
Discussion
----------
[Console] added phpdocs to InputOption constants
| Q | A
| ------------- | ---
| Branch? | 5.x for features / 4.4 or 5.2 for bug fixes <!-- see below -->
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | n/a <!-- required for new features -->
This PR adds phpdocs to the `InputOption` constants. The docs itself were copied over from the docs on https://symfony.com/doc/current/console/input.html#using-command-options.
Over and over again people (including myself) confuse the different available constants.
having the meaning carried with the implementation should help to use the one which actually fits the use-case.
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- Never break backward compatibility (see https://symfony.com/bc).
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too.)
- Features and deprecations must be submitted against branch 5.x.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
-->
Commits
-------
9f124f6278 [Console] : added phpdocs to InputOption constants
* 5.2:
[DoctrineBridge] Allow bundles to define a driver type "attribute"
fix test SocketStreamTest for Windows
Fix issue with RequestMatcher when attribute is a closure
[PropertyInfo] Use the right context for methods defined in traits
* 4.4:
[DoctrineBridge] Allow bundles to define a driver type "attribute"
fix test SocketStreamTest for Windows
Fix issue with RequestMatcher when attribute is a closure
[PropertyInfo] Use the right context for methods defined in traits
This PR was merged into the 5.2 branch.
Discussion
----------
[FrameworkBundle] Fix array controller link in debug:router
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
`debug:router` is broken when you add a route in the Kernel (see https://symfony.com/doc/current/configuration/micro_kernel_trait.html) because `kernel` is not a class and triggers a `\ReflectionException`. The code in the exception handling always expect `$controller` to be a string.
Commits
-------
be964bdfa6 [FrameworkBundle] Fix array controller link in debug:router
This PR was merged into the 4.4 branch.
Discussion
----------
[Mailer] Fix SocketStreamTest for windows
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? |no
| Tickets | -
| License | MIT
| Doc PR | -
**How to reproduce**
PHP 8.0.3
PHPUnit 9.5.4
c:\php\php ./phpunit --bootstrap ./vendor/autoload.php --configuration ./phpunit.xml.dist --filter "/(SocketStreamTest::testSocketErrorNoConnection)( .*)?$/" --test-suffix SocketStreamTest.php ./src/Symfony/Component/Mailer/Tests/Transport/Smtp/Stream --testdox
Failed asserting that exception message 'Connection could not be established with host "ssl://localhost:9999": stream_socket_client(): Unable to connect to ssl://localhost:9999 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)' matches '/Connection refused|unable to connect/'.
Commits
-------
a46fce402c fix test SocketStreamTest for Windows
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle] Add AbstractController::handleForm() helper
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | n/a
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/15217
Some libraries such as Turbo require to strictly follow the HTTP specification (and especially to use proper status codes) to deal with forms.
In https://github.com/symfony/symfony/pull/39843, I introduced a new `renderForm()` helper for this purpose. But I'm not very satisfied by it. The current approach has several problems:
1. It calls `$form->isValid()` two times, which may hurt performance
2. It sets the proper status code in case of validation error (422), but not for the redirection when the entity is created or updated (306). The user must do this manually (and so be aware of these HTTP subtleties).
3. It hides the verbosity of the Form component a bit, but I'm a sure that we can reduce it more
This PR proposes an alternative helper, `handleForm()`, which handles automatically 80% of the use cases, provide an extension point for the other 20%, and can also serve as a quick example for users to handle form in a custom way (by control-clicking on the function to see the code and copy/paste/adapt it).
* if the form is not submitted, the Twig template passed in $view is rendered and a 200 HTTP status code is set
* if the form is submitted but invalid, the Twig template passed in $view is rendered and 422 HTTP status code is set
* if the form is submitted and valid, the entity is saved (only if it is managed by Doctrine ORM), a 306 HTTP status code is set and the Location HTTP header is set to the value of $redirectUrl
Before (standard case):
```php
#[Route('/{id}/edit', name: 'conference_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Conference $conference): Response
{
$form = $this->createForm(ConferenceType::class, $conference);
$form->handleRequest($request);
$submitted = $form->isSubmitted();
$valid = $submitted && $form->isValid();
if ($valid) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('conference_index', [], Response::HTTP_SEE_OTHER);
}
$response = $this->render('conference/edit.html.twig', [
'conference' => $conference,
'form' => $form->createView(),
]);
if ($submitted && !$valid) {
$response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY);
}
return $response;
}
```
With the new helper:
```php
#[Route('/{id}/edit', name: 'conference_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Conference $conference): Response
{
$form = $this->createForm(ConferenceType::class, $conference);
return $this->handleForm(
$request,
$form,
view: 'conference/edit.html.twig',
redirectUrl: $this->generateUrl('conference_index')
);
}
```
Before (more advanced use case):
```php
#[Route('/{id}/edit', name: 'conference_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Conference $conference, HubInterface $hub): Response
{
$form = $this->createForm(ConferenceType::class, $conference);
$form->handleRequest($request);
$submitted = $form->isSubmitted();
$valid = $submitted && $form->isValid();
if ($valid) {
$this->getDoctrine()->getManager()->flush();
$hub->publish(
new Update(
'conference:'.$conference->getId(),
$this->renderView('conference/edit.stream.html.twig', ['conference' => $conference])
)
);
return $this->redirectToRoute('conference_index', [], Response::HTTP_SEE_OTHER);
}
$response = $this->render('conference/edit.html.twig', [
'conference' => $conference,
'form' => $form->createView(),
]);
if ($submitted && !$valid) {
$response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY);
}
return $response;
}
```
With the new helper (more advanced case):
```php
#[Route('/{id}/edit', name: 'conference_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Conference $conference, HubInterface $hub): Response
{
$form = $this->createForm(ConferenceType::class, $conference);
$response = $this->handleForm(
$request,
$form,
view: 'conference/edit.html.twig',
redirectUrl: $this->generateUrl('conference_index')
);
if ($response->isRedirection()) {
$hub->publish(
new Update(
'conference:' . $conference->getId(),
$this->renderView('conference/edit.stream.html.twig', ['conference' => $conference])
)
);
}
return $response;
}
```
This also works without named parameters. I also considered passing a callback to be executed on success, but I'm happier with the current solution.
WDYT?
TODO:
* [x] update tests
Commits
-------
5228546066 [FrameworkBundle] Add AbstractController::handleForm() helper
This PR was merged into the 4.4 branch.
Discussion
----------
[DoctrineBridge] Add support for a driver type "attribute"
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| License | MIT
Without this change its not possible to use attributes for mapping when they get released in ORM 2.9 over the next days. Otherwise we would need to copy three methods from the `AbstractDoctrineExtension` into the Bundle. See the DoctrineBundle PR that makes the full changes: https://github.com/doctrine/DoctrineBundle/pull/1322
Commits
-------
cecaa7815a [DoctrineBridge] Allow bundles to define a driver type "attribute"