This PR was merged into the 4.4 branch.
Discussion
----------
[Debug][ErrorHandler] Avoid warning with Xdebug 3 with develop mode disabled
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40677
| License | MIT
As reported in #40677, this fix is needed when Xdebug 3 is enabled but its `develop` mode is off.
Commits
-------
0e0639b129 Avoid warning with Xdebug 3 with develop mode disabled
This PR was merged into the 5.2 branch.
Discussion
----------
[Security] [Passport] improve dx and document AuthenticationException
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | N/A
| License | MIT
| Doc PR | tbd
`Passport::getUser()` (Instance of `UserPassportInterface::class`) throws an `AuthenticationException::class`
if a user does not exist. Let's document that for better DX and visibility.
Use case:
- User login w/ a `username` that does not exist (custom json authenticator)
- Attempt Authentication...
- Auth failed `LoginFailureEvent` dispatched
- snippet below:
```php
// Userland\LoginFailureEventSubscriber::class
public function dispatchFailure(LoginFailureEvent $event): void
{
$user = $event->getPassport()->getUser();
$message = new UserlandMessage($user);
$this->messageBus->dispatch($message);
}
```
- `401` status is returned.
The above subscriber fails silently because a `UsernameNotFoundException` was ultimately thrown from `UserBadge::getUser()`.
Commits
-------
97ceba0f5d improve dx and document auth exception
A badge on a passport is a critical security element, it determines which
security checks are run during authentication. Using the `required_badges`
setting, applications can make sure the expected security checks are run.
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Mailer][Notifier] added missing gitattributes and gitignore
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| License | MIT
just added missing .gitattributes and .gitignore to be consistent with other components
Commits
-------
00ac6d4b45 added missing gitattributes and gitignore
* 5.2:
added missing gitattributes and gitignore
allow CurlHttpClient on Windows
[Security] Mark ExpiredLoginLinkStorage as experimental
remove references to "Silex"
This PR was merged into the 5.2 branch.
Discussion
----------
[Security] Mark ExpiredLoginLinkStorage as experimental
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
We missed marking this as experimental together with the other "LoginLink" features.
This PR follows the discussion in https://github.com/symfony/symfony/pull/40145/files#r589072524
Commits
-------
76a88f2211 [Security] Mark ExpiredLoginLinkStorage as experimental
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
LoginLink create get Request Locale
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
| Doc PR | symfony/symfony-docs#15163
While writing the documentation for PR#40153 I noticed that the RequestContext :: fromRequest method does not add the '_locale' parameter automaticaly. This new pull request to set _locale parameter to the RequestContext.
Commits
-------
433d76bfe1 LoginLink create get Request Locale
* 5.2:
fixed parser
Fixed bugs found by psalm
[FrameworkBundle] Dont store cache misses on warmup
fix test
Update references to the ContainerConfigurator
[Translation] Remove file added back from a bad merge
Fix sleep value
[Cache] skip storing failure-to-save as misses in ArrayAdapter
[Validator] Delete obsolete statement in Regex::getHtmlPattern() phpDoc
[FrameworkBundle] Remove author comments for configuration and extension
[Stopwatch] Document new "name" property of StopwatchEvent
[DependencyInjection] Fix "url" env var processor behavior when the url has no path
Fixed support for nodes not extending BaseNode
[FrameworkBundle] dont access the container to configure http_cache
add missing queue_name to find(id) in doctrine messenger transport
[Config][FrameworkBundle] Hint to use PHP 8+ or to install Annotations to use attributes/annots
[Serializer] AbstractNormalizer force null for non-optional nullable constructor parameter denormalization when not present in input
* 4.4:
fixed parser
Fixed bugs found by psalm
[FrameworkBundle] Dont store cache misses on warmup
[Cache] skip storing failure-to-save as misses in ArrayAdapter
[Validator] Delete obsolete statement in Regex::getHtmlPattern() phpDoc
[FrameworkBundle] Remove author comments for configuration and extension
[DependencyInjection] Fix "url" env var processor behavior when the url has no path
Fixed support for nodes not extending BaseNode
add missing queue_name to find(id) in doctrine messenger transport
[Serializer] AbstractNormalizer force null for non-optional nullable constructor parameter denormalization when not present in input
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
Fixed bugs found by psalm
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
When running psalm for branch 4.4, we get around 1500 errors. I browsed though them all and here is a small PR with the actual bugs I think should be fixed.
I'll make review comments about them below.
Commits
-------
0a0cd7a274 Fixed bugs found by psalm
This PR was merged into the 4.4 branch.
Discussion
----------
[Config] Fixed support for nodes not extending BaseNode
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
Too many times we assume that a `NodeInterface` extends `BaseNode`. This PR adds a small test with a new `CustomNodeDefinition` and `CustomNode` that implements `NodeInterface`.
Commits
-------
68276562c3 Fixed support for nodes not extending BaseNode
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] Dont store cache misses on warmup
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#38694
| License | MIT
| Doc PR | symfony/symfony-docs#15172
When we are warming the annotation cache, we are reading all annotation into an `ArrayAdapter`. When we are done we move the values to a `PhpArrayAdapter` to store them in a file.
@Seldaek [found out](https://github.com/symfony/symfony/issues/38694#issuecomment-810501066) that when you are using a custom constraint with a `Symfony\Component\Validator\Constraints\Callback`, there is a strange error like:
> Can use "yield from" only with arrays and Traversables
That is because the `Closure` in the `Symfony\Component\Validator\Constraints\Callback` cannot be serialised and saved to cache. But since the `ArrayAdapter` is also [storing misses as null](https://github.com/symfony/symfony/pull/35362), the null values are understood as real values.
When all values are moved to the `PhpArrayAdapter` and we ask the cache for a value (via Doctrine's `CacheProvider`), it will return `null` as a value instead of `false` as a cache miss. And `null` is not something one could "yield from".
Commits
-------
27a22b34af [FrameworkBundle] Dont store cache misses on warmup
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
Improve ExtractorInterface phpdoc
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- 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
-->
I think this phpdoc can be improved
Commits
-------
255b608d6d Improve ExtractorInterface phpdoc
This PR was merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] Remove author comments for configuration and extension
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
I really don't want to step on anyones toes. I'm also super grateful for all the time, effort and energy these contributors (and everybody else) have given to Symfony.
The `@author` tags should represent "who knows the most about this class" or to give the original author some kind of credit (more visible than `git blame`).
The FrameworkBundle's `Configuration` and `FrameworkExtension` classes are a bit special. Fist because they are well known by most recurring contributors. They are also thousands of lines long and many many users have added a line or two. The `FrameworkExtension` have over 50 people that currently authored more than 5 lines. The named authors combined have about that 12% and 25% in `Configuration` and `FrameworkExtension` respectively.
I do like the `@author` tag, but for the reasons above, I don't think they make sense for these classes.
Commits
-------
f19d72aa07 [FrameworkBundle] Remove author comments for configuration and extension
This PR was merged into the 5.3-dev branch.
Discussion
----------
Use symfony/deprecation-contracts instead of trigger_error
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | yes <!-- 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 -->
As `symfony/deprecation-contracts` added to requirements with PR #40468, we can update `trigger_error` call in favor reusing deprecation abstractions
Commits
-------
1acc296773 Use symfony/deprecation-contracts instead of trigger_error
This PR was merged into the 4.4 branch.
Discussion
----------
[Validator] Delete obsolete statement in Regex::getHtmlPattern() phpDoc
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | #12235
| License | MIT
| Doc PR |
The original issue was #5307 (`match=false` not handled in `getHtmlPattern()`).
Then #5382 patched it to return null (rather than an incorrect result) and inserted a statement and a "todo" in the phpDoc.
Later (but still years ago) #12235 properly implemented pattern inversion, but only removed the "todo"; this PR removes the statement.
Commits
-------
3bdf8d7238 [Validator] Delete obsolete statement in Regex::getHtmlPattern() phpDoc
This PR was merged into the 4.4 branch.
Discussion
----------
[DependencyInjection] Fix "url" env var processor behavior when the url has no path
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Before:
```yaml
MY_URL_ENV_VAR=http://symfony.com
%env(key:path:url:MY_URL_ENV_VAR)% --> false
```
After:
```yaml
MY_URL_ENV_VAR=http://symfony.com
%env(key:path:url:MY_URL_ENV_VAR)% --> null
```
Returning `false` for the path prevents me from using the `default` env var processor that is triggered only for `''` and `null`.
(`%env(default:my_fallback_param:key:path:url:MY_URL_ENV_VAR)%`)
BTW, with PHP 8, it actually works because `substr(null, 1)` behavior changed (see https://3v4l.org/oHf6l).
Commits
-------
2876cf9cc6 [DependencyInjection] Fix "url" env var processor behavior when the url has no path
This PR was merged into the 4.4 branch.
Discussion
----------
[Cache] skip storing failure-to-save as misses in ArrayAdapter
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#38694
| License | MIT
| Doc PR | -
In addition to #40645
Commits
-------
ba6698795c [Cache] skip storing failure-to-save as misses in ArrayAdapter
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Mime] Remove @internal from Headers methods
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- 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
-->
I don't understand why the methods
- `Headers::getHeaderBody()`
- `Headers::setHeaderBody()`
- `Headers::getHeaderParameter()`
- `Headers::setHeaderParameter()`
are marked as internal.
They are already used by others libraries, like
a6c3fa9aea/Transport/MandrillApiTransport.php (L92)a6c3fa9aea/Transport/MandrillApiTransport.php (L99)
The implementation shouldn't change so they could be under the BC promise.
Plus they are useful, and I don't see any other way that reimplementing the method if we want to do something like
```
->getHeaderParameter('Content-Disposition', 'name')
```
Commits
-------
592fb13456 Remove internal annotation
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle][HttpKernel][TwigBridge] Add an helper to generate fragments URL
| 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 | Fix n/a
| License | MIT
| Doc PR | todo
This PR adds a new helper to generate raw fragment URL. Fragments will be useful to generate lazy frames with Symfony UX Turbo (https://github.com/symfony/ux/pull/64). This will also be convenient when using hinclude, ESI etc in case you want full control over the generated HTML.
This is also more in sync with the new best practices we apply in the form component (generate the HTML by yourself instead of using Twig helpers hiding the HTML elements).
Example:
```html
<turbo-frame id="set_aside_tray" src="{{ fragment_uri(controller('Symfony\Bundle\FrameworkBundle\Controller', {template: "foo.html.twig"})) }}">
<img src="/icons/spinner.gif">
</turbo-frame>
```
Commits
-------
5d29d76612 [FrameworkBundle][HttpKernel][TwigBridge] Add an helper to generate fragments URL
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
Messenger multiple failed transports
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#34911
| License | MIT
| Doc PR | symfony/symfony-docs#13489
<!--
https://github.com/symfony/symfony-docs/pull/13489 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/roadmap):
- 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 master.
-->
## Strategy applied
- Pass a map of transports and failed transports to the `SendFailedMessageToFailureTransportListener`. This way we re-use the same listener.
- Local failed transport has more priority than a global failed transport defined.
## Configuration example
```yaml
# config/packages/messenger.yaml
framework:
# no need to set failed transport globally if I want a specific behaviour per transport.
failure_transport: failed # all transports have this failed transport
messenger:
transports:
failed: 'doctrine://default?queue_name=failed'
failed_important: 'doctrine://default?queue_name=failed_important'
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
failure_transport: failed # takes precedence over the global defined "failed_transport"
retry_strategy:
max_retries: 3
delay: 1000
multiplier: 2
async_no_failure_transport: # it will use the global defined transport if no one is defined.
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
retry_strategy:
max_retries: 3
delay: 1000
multiplier: 2
async_send_specific_failure_queue:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
failed_transport: failed_important # takes precedence over the global defined "failed_transport"
retry_strategy:
max_retries: 3
delay: 1000
multiplier: 2
```
You can test this feature easily on a [demo project](https://github.com/monteiro/messenger-multiple-failed-transports-pr34979). Just follow the [README](https://github.com/monteiro/messenger-multiple-failed-transports-pr34979).
**More information on issue #34911**
## What needs to be done so this can be merged:
- [x] validate strategy
- [ ] update src/**/CHANGELOG.md files
- [x] update tests to cover all cases
- [x] create doc PR
Commits
-------
5810b6c378 Messenger multiple failed transports
This PR was merged into the 4.4 branch.
Discussion
----------
[Serializer] Allow AbstractNormalizer to use null for non-optional nullable constructor parameters without default value
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40511
| License | MIT
Serializer component AbstractNormalizer attemps to guess constructor parameters, and falls back using default values when possible. Yet, it misses one use case: nullable non-optional parameter with value not being present in incoming input, case in which null is a valid value, not the default one, yet still valid.
This PR introduce a two-line fix that forcefully set null as value for missing from input non-optional nullable constructor parameters values.
Commits
-------
d29e433ae8 [Serializer] AbstractNormalizer force null for non-optional nullable constructor parameter denormalization when not present in input
This PR was merged into the 4.4 branch.
Discussion
----------
add missing queue_name to find(id) in doctrine messenger transport
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| License | MIT
This bug was noticed by @weaverryan when reviewing the PR: https://github.com/symfony/symfony/pull/38468 related to multiple failure transports.
Commits
-------
bb26a92826 add missing queue_name to find(id) in doctrine messenger transport
This PR was merged into the 5.2 branch.
Discussion
----------
[Config][FrameworkBundle] Hint to use PHP 8+ or to install Annotations for using attributes/annots
…s to use attributes/annots
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | See https://github.com/symfony/recipes/pull/916
| License | MIT
| Doc PR | n/a
Improve the error message to hint that you can upgrade to PHP 8 instead of using `doctrine/annotations`.
Commits
-------
af6f3c2c08 [Config][FrameworkBundle] Hint to use PHP 8+ or to install Annotations to use attributes/annots
* 5.2:
skip intl dependent tests if the extension is missing
make DateCaster tests timezone-agnostic
error if the input string couldn't be parsed as a date
IntegerType: Always use en for IntegerToLocalizedStringTransformer Fixes#40456
Uses the correct assignment action for console options depending if they are short or long
[HttpKernel] ConfigDataCollector to return known data without the need of a Kernel
[HttpClient] fix using stream_copy_to_stream() with responses cast to php streams
FIx Trying to clone an uncloneable object of class
* 4.4:
skip intl dependent tests if the extension is missing
make DateCaster tests timezone-agnostic
error if the input string couldn't be parsed as a date
IntegerType: Always use en for IntegerToLocalizedStringTransformer Fixes#40456
Uses the correct assignment action for console options depending if they are short or long
[HttpKernel] ConfigDataCollector to return known data without the need of a Kernel
[HttpClient] fix using stream_copy_to_stream() with responses cast to php streams
FIx Trying to clone an uncloneable object of class
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Serializer] Nicer ExtraAttributesException message for single attribute
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | none
| License | MIT
| Doc PR | n/a
This PR changes wording of ExtraAttributesException message in case there is only one extra attribute:
Before
----
Extra attributes are not allowed ("foo", "bar" are unknown).
Extra attributes are not allowed ("foo" are unknown).
After:
----
Extra attributes are not allowed ("foo", "bar" are unknown).
Extra attributes are not allowed ("foo" is unknown).
Commits
-------
1ba6a2cf50 [Serializer] Nicer ExtraAttributesException message for single attribute
This PR was merged into the 4.4 branch.
Discussion
----------
[Form] error if the input string couldn't be parsed as a date
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40597
| License | MIT
| Doc PR |
When the Intl polyfill is used instead of the PHP intl extension, the
intl_get_error_code() function always returns 0 no matter if the input
string could be parsed.
Commits
-------
5ce5300da3 error if the input string couldn't be parsed as a date
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpClient] fix using stream_copy_to_stream() with responses cast to php streams
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40574
| License | MIT
| Doc PR | -
Commits
-------
cf1404a30b [HttpClient] fix using stream_copy_to_stream() with responses cast to php streams
This PR was merged into the 4.4 branch.
Discussion
----------
[VarDumper] make DateCaster tests timezone-agnostic
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
Commits
-------
bfef4546d3 make DateCaster tests timezone-agnostic
When the Intl polyfill is used instead of the PHP intl extension, the
intl_get_error_code() function always returns 0 no matter if the input
string could be parsed.
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[TwigBridge] add tailwindcss form layout
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | n/a
| License | MIT
| Doc PR | todo
Per @weaverryan's [call to action on twitter](https://twitter.com/weaverryan/status/1369654724107067392) and slack discussion.
It's been tricky to create a generic form layout for tailwind as it's a css *utility framework* and has an unlimited number of ways to style forms. With tailwindcss 2.0, the tailwind team released an [official form plugin](https://github.com/tailwindlabs/tailwindcss-forms) that provides form element reset/normalization that looks decent out of the box. This PR is an attempt to piggy-back on this plugin to provide a minimal Symfony form layout for tailwind. The goal is to have your forms look good in a tailwind/Symfony app with no customization (but of course allow customization as desired).
This layout **requires** tailwindcss 2 and the form plugin.
I followed the ["unstyled" demo](https://tailwindcss-forms.vercel.app/) for the form plugin as a style guide. Here is a screenshot of this layout used in [a demo Symfony app](https://github.com/kbond/symfony-tailwind) with several common form types (I'll try to keep this updated as I update the PR):
![New-Post](https://user-images.githubusercontent.com/127811/112684961-3d2cc380-8e4a-11eb-8e43-0c08d2eecd7a.png)
Some notes about the layout:
1. I tried to use as few tailwind classes as possible and avoid color (primary exception being the error color).
2. I decided on a mobile-first approach so out of the box, it will look decent on any device and drastically reduces the number of css classes/assumptions.
3. While other layouts merge classes passed by the user, I opted to replace. This ensures the user doesn't have to _undo_ the class decisions made by this layout. I also discovered "undoing" doesn't work as I expected anyway: `class="mt-1 mt-0"`, `mt-1` "wins" as `mt-1` comes later in the compiled stylesheet.
4. For the _low level_ blocks, I extracted the classes into their own "variables" (`row_class`, `widget_class`, `label_class`, `help_class`, `error_item_class`) to make it easier to extend and customize the layout. Note the `widget_disabled_class`/`widget_errors_class` variables: these are added even if you've overridden the `widget_class` variable.
### Customization
Customizing is especially important for this layout. Here are the two ways:
1. Twig form functions:
```twig
{{ form_row(form.title, {
row_class: 'my row classes',
label_class: 'my label classes',
error_item_class: 'my error item classes',
widget_class: 'my widget classes',
widget_disabled_class: 'my disabled widget classes',
widget_errors_class: 'my widget with error classes',
}) }}
```
2. Project specific form layout:
```twig
{% use 'tailwind_2_layout.html.twig' %}
{%- block form_row -%}
{%- set row_class = row_class|default('my row classes') -%}
{{- parent() -}}
{%- endblock form_row -%}
{%- block widget_attributes -%}
{%- set widget_class = widget_class|default('my widget classes') -%}
{%- set widget_disabled_class = widget_disabled_class|default('my disabled widget classes') -%}
{%- set widget_errors_class = widget_errors_class|default('my widget with error classes') -%}
{{- parent() -}}
{%- endblock widget_attributes -%}
{%- block form_label -%}
{%- set label_class = label_class|default('my label classes') -%}
{{- parent() -}}
{%- endblock form_label -%}
{%- block form_help -%}
{%- set help_class = help_class|default('my label classes') -%}
{{- parent() -}}
{%- endblock form_help -%}
{%- block form_errors -%}
{%- set error_item_class = error_item_class|default('my error item classes') -%}
{{- parent() -}}
{%- endblock form_errors -%}
```
#### Customization POC/Demo
With this custom form theme:
```twig
{%- block form_label -%}
{%- set label_class = label_class|default('block text-gray-500 uppercase tracking-wider text-sm font-bold') -%}
{{- parent() -}}
{%- endblock -%}
{%- block widget_attributes -%}
{%- set widget_class = widget_class|default('mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50') -%}
{{- parent() -}}
{%- endblock -%}
{%- block checkbox_widget -%}
{%- set widget_class = widget_class|default('mr-2 rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-offset-0 focus:ring-indigo-200 focus:ring-opacity-50') -%}
{{- parent() -}}
{%- endblock -%}
{%- block checkbox_label -%}
{%- set label_class = label_class|default('block text-gray-800') -%}
{{- block('form_label') -}}
{%- endblock -%}
```
The above example looks like this:
![New-Post (3)](https://user-images.githubusercontent.com/127811/112705040-657ce800-8e73-11eb-965f-de289e9b978a.png)
Commits
-------
3719a409b6 [TwigBridge] add tailwindcss form layout
This PR was merged into the 4.4 branch.
Discussion
----------
[Form] IntegerType: Always use en for IntegerToLocalizedStringTransformer
Fixes#40456
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40456
| License | MIT
Commits
-------
83b836dbc9 IntegerType: Always use en for IntegerToLocalizedStringTransformer Fixes#40456
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[HttpKernel] ConfigDataCollector to return known data without the need of a Kernel
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40534
| License | MIT
| Doc PR |
Sets `$this->data` with information that can be known without the need of a `Kernel`.
Commits
-------
d919f2ce83 [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel
This PR was merged into the 4.4 branch.
Discussion
----------
Fix Trying to clone an uncloneable object of class
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Since `ext-redis: 5.3..3`, the `\Redis` class is not cloneable anymore (https://github.com/phpredis/phpredis/commit/cd05a344).
PHPUnit 7.5 (used byt PHP 7.1) clones objects provided by the dataprovier, when they are cloneable.
To check if an object is cloneable, it use the `Reflexion::isCloneable` method and check if the `__clone` method is public.
The issue is, the Class generated by `createMock` is cloneable, which leads to an exception such as:
> Trying to clone an uncloneable object of class Mock_Redis_b2f171b3
This PR fake replaces the mock by a real instance of the class.
Commits
-------
f67dab95e2 FIx Trying to clone an uncloneable object of class
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[Security] LoginLink with specific locale
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
| Doc PR |
I have added the possibility to create a login link for a specific locale. It's useful when we want generate a link for an other user who isn't in the same locale of us.
Commits
-------
50673c5321 [Security] LoginLink with specific locale
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Serializer] Add a Custom End Of Line in CSV File
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
| Doc PR | -
Commits
-------
20f03677e3 [Serializer] Add a Custom End Of Line in CSV File
This PR was merged into the 5.3-dev branch.
Discussion
----------
Add `#[As-prefix]` to service attributes
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This PR renames all existing attributes with the `As` prefix, as I proposed several times already.
This should help autocompletion, and it's required to not collide with existing class names (eg the `Command` class, but also the old `Controller` class, etc.)
I think this `As` prefix is a convention for the better.
Commits
-------
4f1318963a Add `#[As-prefix]` to service attributes
This PR was merged into the 5.3-dev branch.
Discussion
----------
[HttpKernel] Add `#[AsController]` attribute for declaring standalone controllers on PHP 8
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This PR adds an `#[AsController]` attribute to allow autoconfiguring controllers even when they don't extend `AbstractController`. This should allow removing the line about `controller.service_arguments` in `services.yaml` to cover this need (but that is noise to most.)
Commits
-------
437f5feb45 [HttpKernel] Add `#[AsController]` attribute for declaring listeners on PHP 8
* 5.2:
[travis] use packagist API v2
[translation] Fix update existing key with existing +int-icu domain
[Contracts] Fix branch name in README.md links
* 4.4:
[travis] use packagist API v2
[translation] Fix update existing key with existing +int-icu domain
[Contracts] Fix branch name in README.md links
This PR was merged into the 4.4 branch.
Discussion
----------
[Translation] Fix update existing key with existing +int-icu domain
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | none
| License | MIT
| Doc PR | none
Using php-translation webui interface, I was trying to update an existing +int-icu domain but a regular domain was created and the existing key wasn't updated. Looks like in the method I modified, we should have been looking for a potential domain+intl-icu domain and try update it first
Commits
-------
2a196ca0dc [translation] Fix update existing key with existing +int-icu domain
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Notifier] Move abstract test cases to namespace
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no (only fixes builds)
| New feature? | yes (not sure about a changeling entry)
| Deprecations? | no
| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | no
This enables BC promise for the abstract test classes, like for other ones.
As we ignore current `/Tests` directory in `.gitattributes`, builds will fail if `symfony/notifier` is installed as dist.
Commits
-------
33ba3c755d [Notifier] Move abstract test cases to namespace
This PR was merged into the 5.2 branch.
Discussion
----------
Fixed parsing deprecated definitions without message key
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
### Steps to reproduce
1. Create service/alias definition and mark it as deprecated without specifying message key as shown in https://symfony.com/doc/5.2/service_container/alias_private.html#deprecating-service-aliases. For example:
```yaml
services:
service_without_deprecation_message:
class: Foo
deprecated:
package: vendor/package
version: 1.1
alias_without_deprecation_message:
alias: foobar
deprecated:
package: vendor/package
version: 1.1
```
2. Clear cache by running `php bin/console cache:clear`
### Actual behaviour
`Symfony\Component\Config\Exception\LoaderLoadException` exception is thrown with the following message: `Warning: Undefined array key "message" (...)`
See https://gist.github.com/adamwojs/5bac85d4326d8fbe6f52a357fa6e57e6 for full stactrace.
### Excepted behaviour
Given definitions are loaded correctly. Default service/alias deprecation message is used as shown in linked documentation page.
Commits
-------
d585b64953 Fixed parsing deprecated definitions without message key
This PR was merged into the 4.4 branch.
Discussion
----------
[Security] Handle properly 'auto' option for remember me cookie security
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40471
| License | MIT
| Doc PR | n/a
Manually setting remember_me cookie secure as auto is still is being set as secure one even if used over http.
This PR fixes this behaviour by converting auto to null prior setting it up for service.
Commits
-------
2bcf69c071 [Security] Handle properly 'auto' option for remember me cookie security
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[Validator] Avoid triggering the autoloader for user-input values
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
Following-up to https://twitter.com/seldaek/status/1372450636361502721 - mostly to see if the build passes or if this breaks some undocumented/unclear-to-me assumptions.
Essentially using the `Valid` constraint should only validate objects if they exist as objects. If a user sends a string and that gets assigned to a property, `Valid` should not attempt autoloading that user-given string.
As far as I can tell, this is used in two places:
- acb32dd396/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php (L364-L365) where non-objects are anyway ignored, so this change is harmless there.
- acb32dd396/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php (L652-L660) where it's explicitly passing anything in there to get the proper exception, so my change makes sure that exception is thrown *before* autoloading attempts. I am just not 100% sure if there are cases where validateGenericNode will receive a class name as a string to validate in $value. I can't imagine why it would but that doesn't mean it's true.
Commits
-------
e45eb23ba2 [Validator] Avoid triggering the autoloader for user-input values
This PR was merged into the 5.2 branch.
Discussion
----------
[FrameworkBundle] ensure TestBrowserToken::$firewallName is serialized
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | n/a
| License | MIT
| Doc PR | n/a
Fixes a bug introduced in #40368. When `TestBrowserToken` in unserialized, `$firewallName` is `null` so trying to access it via `getFirewallName` throws a `TypeError`.
Commits
-------
8ba12ece57 [FrameworkBundle] ensure TestBrowserToken::$firewallName is serialized
This enables BC promise for the abstract test classes, like for other ones.
As we ignore current `/Tests` directory in `.gitattributes`, builds will fail if `symfony/notifier` is installed as dist.
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Runtime] make GenericRuntime ... generic
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
This PR will allow #40436 to move to https://github.com/symfony/psr-http-message-bridge
For the record, it builds on a prototype I wrote almost one year ago at https://github.com/tchwork/bootstrapper.
This PR makes the `GenericRuntime` implementation able to auto-discover runtime implementations for specific types.
It uses the autoloader for the discovery: when a closure-app requires or returns a type `Vendor\Foo`, it will use a convention and check if the class `Symfony\Runtime\Vendor\FooRuntime` exists. If yes, it will use it to resolve the corresponding type. Such runtime classes have to extend `GenericRuntime` so that they can use the protected API it provides. This requirement is aligned with the fact that the very convention proposed here is an implementation detail that works when using a `GenericRuntime` as the main runtime (This behavior can be overridden by providing explicit entries in the new `runtimes` option when booting the `GenericRuntime`.)
`SymfonyRuntime` can be used as both the main runtime or a type-specific runtime:
- when used as the main runtime, it configures the typical global-state for Symfony and has a fast codepath for Symfony types, while still being generic.
- it can also be used in another runtime as a way to resolve Symfony types (would typically be useful to #40436 for running Console apps in a PSR-based web app.)
Commits
-------
33e371e24d [Runtime] make GenericRuntime ... generic
* 5.2:
[HttpKernel] do is_file check before include
[PhpUnitBridge] fix reporting deprecations from DebugClassLoader
[FrameworkBundle] skip deprecation in integration tests
enable HTTP method overrides as early as possible with the HTTP cache
* 4.4:
[HttpKernel] do is_file check before include
[PhpUnitBridge] fix reporting deprecations from DebugClassLoader
[FrameworkBundle] skip deprecation in integration tests
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpKernel] Add is_file() check before include
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes (?)
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
I recently noticed that on every deployment I got warnings reported by sentry from the `cache:clear` command.
> Warning: include(/var/www/html/var/cache/pro_/App_KernelProdContainer.php): failed to open stream: No such file or directory
In `Symfony\Component\HttpKernel\Kernel` [line 469](https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/HttpKernel/Kernel.php#L469)
(on 4.4 it's on [line 536](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpKernel/Kernel.php#L536))
This is because the code tries to include the `$cachePath` without checking if it exists/is a file first. It seems like something similar was fixed some time ago already (https://github.com/symfony/symfony/pull/27249) some lines above.
This PR fixes the mentioned warnings for me.
I'm running on Symfony 5.2.5 at the moment, but the docs said that bugfixes should target branch 4.4 and new features should target 5.x, and I guess this could rather be seen as a bugfix than a new feature, so I branched off of 4.4 and also set this as target for the PR, I hope that's correct.
Commits
-------
8efcc17573 [HttpKernel] do is_file check before include
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[Form] Add "form_attr" FormType option
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? |no
| New feature? | yes
| Deprecations? | no
| Tickets | N/A
| License | MIT
| Doc PR | [#15108](https://github.com/symfony/symfony-docs/pull/15108)
## What is this about
This PR add support for [`form` attribute](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form) to Symfony Form ([browser compatibility](https://caniuse.com/form-attribute)).
The `form` attribute allows form elements to override their associated form (which is their nearest ancestor form element by default). This is extremely useful to solve **nested form problem** and allows **form children** to be **rendered outside form tag** while still working as expected.
## New "form_attr" FormType option
#### form_attr
**type**: `bool` or `string` **default**: `false`
If set to `true` on a **root form**, adds [`form` attribute](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form) on every children with their root **form id**.
This allows you to render form children outside the form tag and avoid **nested form problem** in some situations while keeping the form working properly.
If set to `true` on a **child**, adds [`form` attribute](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fae-form) on it with its **root form id**.
This allows you to render **that child** outside the form tag and avoid **nested form problem** in some situations while keeping the form working properly.
If root form has no `id` (this may happen by create an *unnamed* form), you can set it to a `string` identifier to be used at `FormView` level to link children and root form anyway.
## Usage on Root Form Example
#### Form Type
Enable the feature by setting `form_attr` to `true` on the root form.
```php
use Symfony\Component\Form\Extension\Core\Type;
class ListFilterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('search', Type\SearchType::class)
->add('orderBy', Type\ChoiceType::class, [
'choices' => [
// ...
],
])
->add('perPage', Type\ChoiceType::class, [
'choices' => [
// ...
],
])
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('form_attr', true); // <--- Set this to true
}
}
```
#### Twig
The following Twig template **works properly** even if form children are **outside** their form tag ([browser compatibility](https://caniuse.com/form-attribute)).
```twig
<div class="header-filters">
{{ form_errors(form) }}
{{ form_row(form.search) }} {# has attribute form="list_filter" #}
{{ form_row(form.orderBy) }} {# has attribute form="list_filter" #}
</div>
<!-- -->
<!-- Some other HTML content, like a table or even another Symfony form -->
<!-- -->
<div class="footer-filters">
{{ form_row(form.perPage) }} {# has attribute form="list_filter" #}
</div>
{{ form_start(form) }} {# id="list_filter" #}
{{ form_end(form) }}
```
✅ Every form elements work properly even outside form tag.
## Usage on Form Child Example
Enable the feature by setting `form_attr` to `true` on selected child.
```php
use Symfony\Component\Form\Extension\Core\Type;
class ListFilterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('search', Type\SearchType::class)
->add('orderBy', Type\ChoiceType::class, [
'choices' => [
// ...
],
])
->add('perPage', Type\ChoiceType::class, [
'form_attr' => true, // <--- Set this to true
'choices' => [
// ...
],
])
}
}
```
#### Twig
The following Twig template **works properly** even if `form.perPage` is **outside** form tag ([browser compatibility](https://caniuse.com/form-attribute)).
```twig
<div class="header-filters">
{{ form_start(form) }} {# id="list_filter" #}
{{ form_errors(form) }}
{{ form_row(form.search) }}
{{ form_row(form.orderBy) }}
{{ form_end(form, {'render_rest': false}) }}
</div>
<!-- -->
<!-- Some other HTML content, like a table or even another Symfony form -->
<!-- -->
<div class="footer-filters">
{{ form_row(form.perPage) }} {# has attribute form="list_filter" #}
</div>
```
✅ `form.perPage` element work properly even outside form tag.
Commits
-------
5f913cec74 [Form] Add "form_attr" FormType option
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[Validator] Add normalizer option to Unique constraint
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | #37451
| License | MIT
| Doc PR | todo
Hello! Reopening my PR #37507 with target branch `5.x`
This PR is about https://github.com/symfony/symfony/issues/37451. The idea is to make that constraint more flexible and able to process business rules, especially when working with objects. We can think about it as the similar feature in UniqueEntity constraint, when we declare on which attributes we are applying the constraint. But in our case it is more general - we pass a callable with whatever logic we want to apply to collection elements before we apply 'uniqueness check' :)
Looks like no BC breaks. Thanks! :)
Commits
-------
44e1e8bc9b [Validator] Add normalizer option to Unique constraint
This PR was merged into the 5.3-dev branch.
Discussion
----------
[DebugBundle] Remove warning of ServerDumpPlaceholderCommand in console
| Q | A
| ------------- | ---
| Branch? | 5.2.5
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40495
| License | MIT
| Doc PR |
In 5.2.5 the console commands are lazy. (https://github.com/symfony/symfony/pull/39851)
With this change the ServerDumpCommand::$defaultName is used which isn't set in the placeholder command.
If no vardump-server in debug.dump_destination is defined, this will lead to a warning and not adding the command to the console list.
Commits
-------
37b2a19989 [DebugBundle] Add $defaultName to PlaceholderCommand