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
* 5.2:
[Console] Fix line wrapping for decorated text in block output
[Inflector] Fixed pluralize "coupon"
[PhpUnitBridge] fix compat with symfony/debug
[VarDumper] Adds support for ReflectionUnionType to VarDumper
Correctly clear lines for multi-line progress bar messages.
[Security] Add XML support for authenticator manager
* 4.4:
[Console] Fix line wrapping for decorated text in block output
[Inflector] Fixed pluralize "coupon"
[PhpUnitBridge] fix compat with symfony/debug
[VarDumper] Adds support for ReflectionUnionType to VarDumper
Correctly clear lines for multi-line progress bar messages.
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[Console] Fix line wrapping for decorated text in block output
| Q | A
| ------------- | ---
| Branch? |
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
Fixed bug that caused decorated text to be wrapped too early in SymfonyStyle->block().
Commits
-------
760be88310 [Console] Fix line wrapping for decorated text in block output
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Runtime] Remove "docs" from readme
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/15081
Make the readme of the Runtime component link to the docs. This PR is blocked by the doc PR.
Commits
-------
6f4552fcec [Runtime] Remove "docs" from readme
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[VarDumper] Adds support for ReflectionUnionType to VarDumper
Fixes a bug with VarDumper when dumping a ReflectionUnionType.
> PHP Error: Call to undefined method ReflectionUnionType::isBuiltin()
Notes:
* One of the existing tests relies on its position in the test file. I had to modify its expected line number.
* There is an existing trailing space around line 367 in an expected value.
I'm not sure if this was left for BC reasons but it seems like a bug if the dumper is leaving trailing spaces.
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
This commit fixes a crash when dumping ReflectionUnionType. The code is minimal but uses a few extra lines to preserve key order for bc and consistency. Additionally, there is an else condition that is currently unreachable but is defensive should they add additional subtypes of ReflectionType. Tests are included. Please let me know if you have any questions or suggestions. Thanks for Symfony it's a wonderful project.
Commits
-------
1a11491f6e [VarDumper] Adds support for ReflectionUnionType to VarDumper
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Mailer] Add supported auth modes to exception
| Q | A
| ------------- | ---
| Branch? | 4.4+
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
If there is no match for the available authenticators the thrown exception now includes the supported auth methods as reported by the server.
Commits
-------
d9c99d86ab [Mailer] Add supported auth modes to exception
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Security] Fix BC layer
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Tests were broken because no password hasher was configured for the new `InMemoryUser` class in configs on lower branches.
This PR fixes it by making the new class extend the deprecated one, so that the password hasher factory is able to find a password hasher for it (instanceof-based match).
Commits
-------
2d7f7b5072 [Security] Fix BC layer
This PR was merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] accept null index in #[TaggedItem]
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
As hinted by @stof in https://github.com/symfony/symfony/pull/40248#discussion_r595065941
Commits
-------
6d16fac703 [DI] accept null index in #[TaggedItem]
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Security] Rename User to InMemoryUser
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| Tickets | Closes#26348
| License | MIT
| Doc PR | -
This PR aims to clarify that the `User` class should only be used by the `InMemoryUserProvider`, as documented:
c06a76c384/src/Symfony/Component/Security/Core/User/User.php (L15-L17)
It also renames `UserChecker` to `InMemoryUserChecker` because it only works with the in-memory user class:
c06a76c384/src/Symfony/Component/Security/Core/User/UserChecker.php (L31-L32)
Commits
-------
55b51d3f90 [Security] Rename User to InMemoryUser
This PR was merged into the 5.3-dev branch.
Discussion
----------
Deprecate configuring tag names and service ids in compiler passes
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | yes
| Tickets | -
| License | MIT
| Doc PR | -
This PR is aimed at reducing the code complexity by hardcoding the name of tags and service ids that compiler passes have to deal with.
I think making these names configurable only adds boilerplate and maintenance overhead for no benefit:
- for the practice: the need to use a pass with a renamed tag/id should be extremely rare (do yo know any?)
- for the theory: a decorating pass could still rename before/after the processing, so this use case is still supported.
Side note: I skipped updating changelog+upgrade files. This would be just noise to me (nobody uses this possibility anyway ;) )
Commits
-------
6fe82d8be7 Deprecate configuring tag names and service ids in compiler passes
* 5.2:
[ErrorHandler] Fix error caused by `include` + open_basedir
[FrameworkBundle] Make the TestBrowserToken interchangeable with other tokens
[Console] ProgressBar clears too many lines on update
[FrameworkBundle] Exclude unreadable files when executing About command
[Bridge\Twig] Add 'form-control-range' for range input type
Be explicit about transparent background color of links in toolbar
[Translation] fix test case name
[Cache] Fix wrong namespace in test
[DependencyInjection] Fix return type
* 4.4:
[Console] ProgressBar clears too many lines on update
[FrameworkBundle] Exclude unreadable files when executing About command
[Bridge\Twig] Add 'form-control-range' for range input type
Be explicit about transparent background color of links in toolbar
[Translation] fix test case name
[Cache] Fix wrong namespace in test
[DependencyInjection] Fix return type
This PR was squashed before being merged into the 5.2 branch.
Discussion
----------
[FrameworkBundle] Make the TestBrowserToken interchangeable with other tokens
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
For some reason most tokens implement getFirewallName (and the deprecated getProviderKey), but not all. This adds it to TestBrowserToken because it caused issues in my tests when upgrading to Symfony 5's `Client::loginUser()`.
I am also happy to add this to AnonymousToken but I am more worried about BC impacts there, so I left it alone for now. All other token classes implement it, so I am not sure why this isn't in TokenInterface to begin with.
Commits
-------
a4958ae7ad [FrameworkBundle] Make the TestBrowserToken interchangeable with other tokens
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[Console] ProgressBar clears too many lines on update
| 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
The ProgressBar incorrectly calculates line lengths when updating, including non-displayable characters such as ANSI colors. This causes it to clear too many lines if the terminal width is greater than the displayed line length but less than the line length including non-displayed characters. An example of this bug in action is https://github.com/acquia/cli/issues/467
Commits
-------
2aa3df0c74 [Console] ProgressBar clears too many lines on update
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] Exclude unreadable files when executing About command
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix https://github.com/symfony/symfony/issues/39916
| License | MIT
| Doc PR | ~
Fix as explained in: https://github.com/symfony/symfony/issues/39916.
Tests failed looks like not releated to my changes.
Commits
-------
25f503a813 [FrameworkBundle] Exclude unreadable files when executing About command
This PR was merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] Add `#[TaggedItem]` attribute for defining the index and priority of classes found in tagged iterators/locators
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Next to #39804, this PR adds a new `#[TaggedItem]` attribute that ppl can use to define the index of their service classes when they're used in tagged collections (iterators/locators.
This replaces the `public static getDefaultName()` and `getDefaultPriority()` methods that ppl could use for this purpose:
```php
#[TaggedItem(index: 'api.logger', priority: 123)]
class MyApiLogger implements LoggerInterface
{
}
```
This will ship the corresponding service at index `api.logger`, priority=123 when building locators/iterators.
Commits
-------
252f2ca1fb [DependencyInjection] Add `#[TaggedItem]` attribute for defining the index and priority of classes found in tagged iterators/locators
This PR was merged into the 4.4 branch.
Discussion
----------
Be explicit about anchor background color in profiler toolbar
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
Hello,
we have a project where we work with background colors on links. When we define this in our stylesheet, the Web Profiler picks these styles up due to the cascade. We added two CSS statements to the Web Profiler stylesheet to be explicit about the transparent background.
![2021-03-15 16_10_08](https://user-images.githubusercontent.com/4400435/111176325-860e8d80-85a9-11eb-82c4-7954aa01245a.png)
![2021-03-15 16_10_30](https://user-images.githubusercontent.com/4400435/111176328-86a72400-85a9-11eb-9515-280c5593a288.png)
Commits
-------
f0cac47ae7 Be explicit about transparent background color of links in toolbar
* 5.2:
[Mailer] fix lowest allowed dependencies
Refresh original user in SwitchUserListener.
check if templating engine supports view
[Mime] Escape commas in address names
* 4.4:
[Mailer] fix lowest allowed dependencies
Refresh original user in SwitchUserListener.
check if templating engine supports view
[Mime] Escape commas in address names
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Validator] Add Validation::createIsValidCallable() that returns a boolean instead of exception
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | Fix#36820
| License | MIT
| Doc PR | tbd
This adds a `Validator::createValidCallable()` (I'm very open for other name suggestions) that returns a boolean instead of exceptions. This allows usingit in places where booleans are expected, for instance in the referenced OptionsResolver case:
```php
$resolver->setAllowedValues('name', Validation::createValidCallable(
new Assert\Length(['min' => 10 ])
));
```
Commits
-------
e731f5fda9 [Validator] Add createValidCallable() that returns a boolean
This PR was merged into the 4.4 branch.
Discussion
----------
[Mime] Escape commas in address names
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#39416
| License | MIT
| Doc PR | --
<!--
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.
-->
Before:
```php
$address = new Address('fabien@symfony.com', 'Fabien, Potencier');
$address->toString(); // Fabien, Potencier <fabien@symfony.com> -> Interpreted like two emails
```
After:
```php
$address = new Address('fabien@symfony.com', 'Fabien, Potencier');
$address->toString(); // "Fabien, Potencier" <fabien@symfony.com>
```
Commits
-------
39e9158999 [Mime] Escape commas in address names
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Console] improve exception message when required argument is added after an optional one
| Q | A
| ------------- | ---
| Branch? | 5.x <!-- see below -->
| Bug fix? | no
| New feature? | wouldn't say so, rather DX improvement <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#40302 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | n/a
Hello, this is my first contribution to Symfony Framework. It's time to pull my weight.
About the issue:
I did improve an error message to include passed argument's name and the latest optional argument's name.
![Screenshot at 2021-02-26 23-08-10](https://user-images.githubusercontent.com/79662742/109361609-8f011e80-7889-11eb-8700-cbbd388c0109.png)
An author also mentioned "But which command?", however this is shown twice as we can see on the screenshot above so I skipped that.
Commits
-------
9bddbbd7ed#40302 improve exception message when required argument is added after an optional one
This PR was merged into the 5.3-dev branch.
Discussion
----------
[HttpFoundation] Use InputBag for POST requests too
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Partially revert #37265
| License | MIT
| Doc PR | -
#37265 was created as a fix for #37100. However, when #37327 was merged, the original bug was also fixed with a different solution (allowing null values on `InputBag::set`) and parts of #37265 are not needed anymore. By using only `InputBag` as the `$request` bag we can tighten the typehint again and make static analysis a bit more useful.
Commits
-------
381a0a19f7 use InputBag for POST requests too, added missing scalar type hints
This PR was merged into the 4.4 branch.
Discussion
----------
Check if templating engine supports given view
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Currently the `ControllerTrait::render` and `ControllerTrait::renderView` methods assume that when the `templating` service is available it can always render the given view via that service.
However, that might not be the case. For example if `framework.templating` is not configured to support the `twig` engine for example but only some other custom engine, e.g.
```yaml
framework:
templating:
engines:
- foobar
```
it will fail when the given view references a Twig template for instance and the configured engine cannot render that.
The `Symfony\Component\Templating\EngineInterface` which `templating` implements defines a `support` method:
2536e178b1/src/Symfony/Component/Templating/EngineInterface.php (L56-L63)
which should be used here, in order to make sure that `templating` actually does support rendering the given view.
Commits
-------
0f9434c189 check if templating engine supports view
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle] Add KernelTestCase::getContainer()
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| Tickets |
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/14731
There are at least 3 ways to get the container in a test class:
```php
class FooTest extends WebTestCase
{
public function testGetContainerA()
{
$kernel = self::bootKernel();
$container = $kernel->getContainer();
}
public function testGetContainerB()
{
self::bootKernel();
$container = self::$container;
}
public function testGetContainerC()
{
$client = self::createClient();
$container = $client->getContainer();
}
}
```
I suggest to add a fourth =)
Basically, in tests you should always use the `test.service_container`. It is hard to remove A and C, but I can deprecate C and add a helper function.
```php
class FooTest extends WebTestCase
{
public function testGetContainerTheOnlyWayYouShouldUse()
{
$container = $this->getContainer();
}
}
```
This new way will also boot your kernel if it is not already booted.
Commits
-------
f4c97240ff [FrameworkBundle] Add KernelTestCase::getContainer()
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[FrameworkBundle] AnnotationsCacheWarmer should support doctrine/annotations:^1.13
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40353
| License | MIT
| Doc PR |
The `AnnotationsCacheWarmer` is creating a cached a `new CachedReader` in the `doWarmUp()`. But this will fail if doctrine/cache is not installed. In #40338 I added the `kernel.cache_warmer` tag on `annotations.cache_warmer` service even though the doctrine/cache is not installed.
This PR will make sure `AnnotationsCacheWarmer` is using the `PsrCacheReader` when available.
This bug was not found in the tests because doctrine/cache is always installed.
----------
Big golden star to @jrushlow because you test dev-master.
Commits
-------
fb1cc72b18 [FrameworkBundle] AnnotationsCacheWarmer should support doctrine/annotations:^1.13
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[WebProfilerBundle] Disable CSP if dumper was used
| Q | A
| ------------- | ---
| Branch? | 5.x for features
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix#29084
| License | MIT
| Doc PR | -
Disables a configured Content Security Policy if the dumper was used to avoid breaking the toolbar. This is a less invasive alternative to #29155 which fixes#29084 (there is a project with a test case linked there).
Commits
-------
5dc2637263 [WebProfilerBundle] Disable CSP if dumper was used
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[twig-bridge] Allow NotificationEmail to be marked as public
| Q | A
| ------------- | ---
| Branch? | 5.x for features
| Bug fix? |no
| New feature? | yes
| Deprecations? |no
| Tickets | Fix#37879
| License | MIT
| Doc PR | -
Closes https://github.com/symfony/symfony/issues/37879
`NotificationEmail` can be created public from the `asPublicEmail` method in any context but with the Notifier component. In this case it is created by it as not public and therefore displays the importance in the subject of the email.
For end users, aka not admin, the importance in the subject's email is not necessary.
This PR will allow if needed to set a `NotificationEmail` as public even after being created, wherever it was created.
I am not sure how to handle the version in the changelog.
For the tests I don't know what's the policy so I just added a new case in each test case.
Commits
-------
8f753d27f2 [twig-bridge] Allow NotificationEmail to be marked as public
* 5.2:
bug #40427 [Console] Stop accepting ints as InputOption defaults
Fix fingerprint when context is not serializable
Fix `ConstraintViolation#getMessageTemplate()` to always return `string`
This PR was merged into the 4.4 branch.
Discussion
----------
[Console] Fix type of InputOption::$default
Options can also be `int`s. So add this type to the PHPDoc parameter
type annotation of `InputInterface::setOption` and the return type
annotation of `InputInterface::getOption`.
| Q | A
| ------------- | ---
| Branch? | 4.4 or 5.2 for bug fixes
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40427
| License | MIT
Commits
-------
3a2d1b4a0a bug #40427 [Console] Stop accepting ints as InputOption defaults
The types accepted and provided by `InputInterface::getOption`
and `setOption` do not include `int` (and passing something like
`--option=123` will set the option to the string `"123"`, not
to the integer `123`).
The `InputOption` default types should match this.
This PR was merged into the 5.2 branch.
Discussion
----------
Fix `ConstraintViolation#getMessageTemplate()` to always return `string`
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is
to be returned by it at all times, yet the implementation returns `null` when no message
template had been provided at instantiation.
This patch obviates it, returning an empty string when the
message template is `null`.
Ref: https://github.com/symfony/symfony/pull/40415#issuecomment-792839512
Commits
-------
72a464e449 Fix `ConstraintViolation#getMessageTemplate()` to always return `string`
* 5.2:
Bump Symfony version to 5.2.6
Update VERSION for 5.2.5
Update CHANGELOG for 5.2.5
Update translations for Norwegian Nynorsk (nn) #38756
Fix eventListener initialization when eventSubscriber constructor dispatch an event
[FrameworkBundle] fix XSD
clear unchecked choice radio boxes even if clear missing is set to false
Fix `ConstraintViolation#getPropertyPath()` to always return `string`
[ErrorHandler] Added missing type annotations to FlattenException
[TwigBridge] Allow version 3 of the Twig extra packages
Fix FrameworkBundle PropertyAccess definition when not in debug
* 4.4:
Update translations for Norwegian Nynorsk (nn) #38756
Fix eventListener initialization when eventSubscriber constructor dispatch an event
clear unchecked choice radio boxes even if clear missing is set to false
[ErrorHandler] Added missing type annotations to FlattenException
[TwigBridge] Allow version 3 of the Twig extra packages
Fix FrameworkBundle PropertyAccess definition when not in debug
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Runtime] a new component to decouple applications from global state
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/15081
Follow up of #36652, see discussion there.
What if we could decouple the bootstrapping logic of our apps from any global state?
This PR makes it possible via a new proposed `symfony/runtime` component.
The immediate benefit this provides is easier maintenance of Symfony apps: code that is currently shipped by recipes will be able to move to `vendor/`. Read the previous sentence twice, this is big :)
Check the following PR to see how far this goes: https://github.com/symfony/recipes/pull/787
The longer-term benefit is being able to run the exact same app under several runtimes: PHP-FPM, CLI, but also PHP-PM and similar. Thanks to the proposed interface, this benefit could span to any PHP apps; not only to apps using the Symfony HttpKernel/HttpFoundation components. This part could be moved to `symfony/contracts` in the future.
Performance-wise, I measured no significant difference with the current way of running apps.
RuntimeInterface
----------------
The core of this component is the `RuntimeInterface` which describes a high-order
runtime logic.
It is designed to be totally generic and able to run any application outside of
the global state in 6 steps:
1. the main entry point returns a callable that wraps the application;
2. this callable is passed to `RuntimeInterface::getResolver()`, which returns a
`ResolverInterface`; this resolver returns an array with the (potentially
decorated) callable at index 0, and all its resolved arguments at index 1;
3. the callable is invoked with its arguments; it returns an object that
represents the application;
4. that object is passed to `RuntimeInterface::getRunner()`, which returns a
`RunnerInterface`: an instance that knows how to "run" the object;
5. that instance is `run()` and returns the exit status code as `int`;
6. the PHP engine is exited with this status code.
This process is extremely flexible as it allows implementations of
`RuntimeInterface` to hook into any critical steps.
Autoloading
-----------
This package registers itself as a Composer plugin to generate a
`vendor/autoload_runtime.php` file. This file shall be required instead of the
usual `vendor/autoload.php` in front-controllers that leverage this component
and return a callable.
Before requiring the `vendor/autoload_runtime.php` file, set the
`$_SERVER['APP_RUNTIME']` variable to a class that implements `RuntimeInterface`
and that should be used to run the returned callable.
Alternatively, the class of the runtime can be defined in the `extra.runtime.class`
entry of the `composer.json` file.
A `SymfonyRuntime` is used by default. It knows the conventions to run
Symfony and native PHP applications.
Examples
--------
This `public/index.php` is a "Hello World" that handles a "name" query parameter:
```php
<?php
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $request, array $context): void {
// $request holds keys "query", "body", "files" and "session",
// which map to $_GET, $_POST, $_FILES and &$_SESSION respectively
// $context maps to $_SERVER
$name = $request['query']['name'] ?? 'World';
$time = $context['REQUEST_TIME'];
echo sprintf('Hello %s, the current Unix timestamp is %s.', $name, $time);
};
```
This `bin/console.php` is a single-command "Hello World" application
(run `composer require symfony/console` before launching it):
```php
<?php
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (Command $command) {
$command->addArgument('name', null, 'Who should I greet?', 'World');
return $command->setCode(function (InputInterface $input, OutputInterface $output) {
$name = $input->getArgument('name');
$output->writeln(sprintf('Hello <comment>%s</>', $name));
});
};
```
The `SymfonyRuntime` can resolve and handle many types related to the
`symfony/http-foundation` and `symfony/console` components.
Check its source code for more information.
Commits
-------
61b32ab2a3 [Runtime] a new component to decouple applications from global state
This PR was merged into the 5.3-dev branch.
Discussion
----------
Don't use sprintf in trigger_deprecation() calls
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Old habits die hard :)
Commits
-------
9ba8f0567d Don't use sprintf in trigger_deprecation() calls
`ConstraintViolation#getMessageTemplate()`'s inherited signature states that `string` is
to be returned by it at all times, yet the implementation returns `null` when no message
template had been provided at instantiation.
This patch obviates it, returning an empty string when the
message template is `null`.
Ref: https://github.com/symfony/symfony/pull/40415#issuecomment-792839512
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[DependencyInjection] Add support an integer return for default_index_method
| Q | A
| ------------- | ---
| Branch? | 5.x for features
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | #40319
| License | MIT
| Doc PR | TODO
Commits
-------
f0922c70d6 [DependencyInjection] Add support an integer return for default_index_method
This PR was merged into the 5.2 branch.
Discussion
----------
Fix `ConstraintViolation#getPropertyPath()` to always return `string`
| Q | A
| ------------- | ---
| Branch? | 5.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets |
| License | MIT
| Doc PR |
`ConstraintViolation#getPropertyPath()`'s inherited signature states that `string` is
to be returned by it at all times, yet the implementation returns `null` when no property
path had been provided at instantiation.
This patch obviates it, returning an empty string when the
property path is `null`.
Commits
-------
7d1029b907 Fix `ConstraintViolation#getPropertyPath()` to always return `string`
This PR was merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] Fix PropertyAccess definition when not in debug
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
The signature of the `PropertyAccessor::createCache()` method specifies that the first argument must be a string but in the `FameworkBundle` configures its DIC with a first argument to `null`. Replacing `null` by `''` allows to respect the contact of `PropertyAccessor::createCache()` and removes the following error when the `symfony/framework-bundle` is blocked in `4.4` but the symfony/property-access goes up to `5.2`.
```
Argument 3 passed to Symfony\Component\PropertyAccess\PropertyAccessor::createCache() must be of the type string, null given, called in /usr/src/app/var/cache/prod/ContainerDX7KWI4/getCache_PropertyAccessService.php on line 12
```
Commits
-------
116c54a554 Fix FrameworkBundle PropertyAccess definition when not in debug
This PR was merged into the 4.4 branch.
Discussion
----------
[Form] clear unchecked choice radio boxes even if clear missing is set to false
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#16802
| License | MIT
| Doc PR |
Commits
-------
e7b4851ea0 clear unchecked choice radio boxes even if clear missing is set to false
This PR was merged into the 5.3-dev branch.
Discussion
----------
[PropertyAccess] use bitwise flags to configure when the property accessor should throw
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | yes
| Tickets | Fix#31126
| License | MIT
| Doc PR |
Commits
-------
a50cfcb49d use bitwise flags to configure when the property accessor should throw
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Cache] boost perf by wrapping keys validity checks with `assert()`
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
PSR-6 has one perf hog: checking the validity of keys.
But in practice, an invalid key should never happen in production: encoding/cleanup is a must-have, and it's a step that should be identified *during dev*.
That's why I think we're safe wrapping these checks with `assert()`.
On an `ArrayAdapter`, this doubles the throughput of the pool when getting items.
I didn't use `assert()` in constructors when not on the hot path.
This PR also makes some callable properties static, as they should be from the beginning.
Commits
-------
8f03a1f555 [Cache] boost perf by wrapping keys validity checks with `assert()`
This PR was merged into the 4.4 branch.
Discussion
----------
[ErrorHandler] Added missing type annotations to FlattenException
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#40385
| License | MIT
| Doc PR | N/A
This class has no constructor where the properties' types could be inferred from. If we want potential contributors (and our serializer, see #40385) to read that code, I think it's only fair that we document the property types via doc blocks.
Commits
-------
d68832e1b9 [ErrorHandler] Added missing type annotations to FlattenException
Motivations for this change:
* Avoid an unneded preg call, explode+implode is faster
* The previous regex created to suboptimal expressions,
due to the pipe that caused empty to be matched.
That means an input like `foo:bar`
was translated into `foo[^:]*[^:]*:bar[^:]*[^:]*`
instead of simply `foo[^:]*:bar[^:]*`
`ConstraintViolation#getPropertyPath()`'s inherited signature states that `string` is
to be returned by it at all times, yet the implementation returns `null` when no property
path had been provided at instantiation.
This patch obviates it, returning an empty string when the
property path is `null`.
* 5.2:
[WebLink] Removed unused property
Fix method name compare in ResolveControllerNameSubscriber
add uz security validator and form validator file
uzb translation
* 4.4:
[WebLink] Removed unused property
Fix method name compare in ResolveControllerNameSubscriber
add uz security validator and form validator file
uzb translation
This PR was merged into the 4.4 branch.
Discussion
----------
[WebLink] Removed unused property
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | N/A
| License | MIT
| Doc PR | N/A
In `Link::withHref()`, a property `templated` is written, that is never declared or access anywhere else. I assume that this is dead code.
Commits
-------
848972e830 [WebLink] Removed unused property
This PR was merged into the 4.4 branch.
Discussion
----------
[FrameworkBundle] [4.4]: Fix method name compare in ResolveControllerNameSubscriber
| 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 -->
| 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 -->
The left side to `strtolower` was not actually lowercased, so it would be always `false`.
The bug was introduced in 6c109c71a9 (https://github.com/symfony/symfony/pull/31938)
<!--
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
-------
69431a3db3 Fix method name compare in ResolveControllerNameSubscriber
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Security] Decouple passwords from UserInterface
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | yes
| Tickets | #23081, helps with #39308
| License | MIT
| Doc PR | todo
This PR addresses a long-standing issue of the Security component: UserInterface is coupled to passwords.
It does it by moving the `getPassword()` method from `UserInterface` to a `PasswordAuthenticatedUserInterface`, and the `getSalt()` method to a `LegacyPasswordAuthenticatedUserInterface`.
Steps:
- In 5.3, we add the new interface and, at places where password-based authentication happens, trigger deprecation notices when a `UserInterface` object does not implement the new interface(s). The UserInterface is kept as-is until 6.0.
- In 6.0, we can remove the methods from `UserInterface` as well as support for using password authentication with user objects not implementing the new interface(s).
As a side-effect, some password-related interfaces (`UserPasswordHasherInterface` and `PasswordUpgraderInterface`) must change their signatures to type-hint against the new interface.
That is done in a BC way, which is to make the concerned methods virtual until 6.0, with deprecation notices triggered from callers and concrete implementations.
Benefits:
In 6.0, applications that use password-less authentication (e.g. login links) won't need to write no-op `getPassword()` and `getSalt()` in order to fulfil the `UserInterface` contract.
For applications that do use password-based authentication, they will need to opt-in explicitly by implementing the relevant interface(s).
This build on great discussions with @wouterj and @nicolas-grekas, and it is part of the overall rework of the Security component.
Commits
-------
2764225a38 [Security] Decouple passwords from UserInterface