Commit Graph

47682 Commits

Author SHA1 Message Date
Jules Pietri
de74794acf [FrameworkBundle][Routing] added Configurators to handle template and redirect controllers 2020-02-09 17:37:08 +01:00
Fabien Potencier
9bfa25869a feature #35373 [Translation] Support name attribute on the xliff2 translator loader (Taluu)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Translation] Support name attribute on the xliff2 translator loader

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #32048
| License       | MIT
| Doc PR        | not done yet

Support using the `name` attribute on the `unit` element in xliff 2.0 to use as the "translation key" rather than always relying on the `<source>` content, as was done on the xliff 1.2.

Commits
-------

37b31149c6 Support name attribute on the xliff2 translator loader
2020-02-09 08:48:01 +01:00
Nicolas Grekas
083a32dee3 Merge branch '5.0'
* 5.0:
  Add missing symfony/mime to require-dev
  [Validator] Added the missing Mongolian translations
  [ErrorHandler] Never throw on warnings triggered by assert() and set assert.exception=1 in Debug::enable()
  refactor(Process): fromShellCommandLine
  [Mailer] Do not ping the SMTP server before sending every message
2020-02-08 18:01:13 +01:00
Nicolas Grekas
255a748f1f Merge branch '4.4' into 5.0
* 4.4:
  Add missing symfony/mime to require-dev
  [Validator] Added the missing Mongolian translations
  [ErrorHandler] Never throw on warnings triggered by assert() and set assert.exception=1 in Debug::enable()
  refactor(Process): fromShellCommandLine
  [Mailer] Do not ping the SMTP server before sending every message
2020-02-08 18:00:58 +01:00
Nicolas Grekas
48272f000a Add missing symfony/mime to require-dev 2020-02-08 17:59:15 +01:00
Nicolas Grekas
c771557213 Merge branch '3.4' into 4.4
* 3.4:
  [Validator] Added the missing Mongolian translations
2020-02-08 17:57:24 +01:00
Fabien Potencier
ebdcd63576 feature #35550 Leverage trigger_deprecation() from symfony/deprecation-contracts (nicolas-grekas)
This PR was merged into the 5.1-dev branch.

Discussion
----------

Leverage trigger_deprecation() from symfony/deprecation-contracts

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Here is what it could mean to use `deprecated()` from #35526 in the code base.

Commits
-------

3e35d8e9e3 Leverage trigger_deprecation() from symfony/deprecation-contracts
2020-02-08 15:35:51 +01:00
Nicolas Grekas
3e35d8e9e3 Leverage trigger_deprecation() from symfony/deprecation-contracts 2020-02-08 15:04:50 +01:00
Fabien Potencier
55e2c5b37d feature #35648 [Contracts/Deprecation] don't use assert(), rename to trigger_deprecation() (nicolas-grekas)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Contracts/Deprecation] don't use assert(), rename to trigger_deprecation()

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This PR is a follow up the discussion that happened in #35526.

I applied all the suggestions I received so far on this previous PR so that we can discuss them all together.

Here are the changes:
- the most important change is to *not* use `assert()` anymore. This fixes the objection from @ostrolucky and @derrabus that deprecations and assert() should not be bound to each other. Instead, in order to still make the function a no-op when wanted, it is suggested that apps declare an empty function. This will be more flexible in practice I believe and keeps all the benefits we envisioned by using assert();
- as suggested by @fabpot, the function is renamed `trigger_deprecation()` instead of `deprecated()`. Because the implementation is now not conditional anymore (from the package pov, since assert() is not used), my arguments to keep the previous name don't stand as strong as before to me so I'm fine renaming.
- type hints are added back (requiring PHP 7.1 to use `void`). As mentioned in the 1st point, ppl that really want deprecations to be no-ops will redeclare the function as empty, thus not using any types, thus reclaiming all the perf diff. And for ppl that do want to catch deprecations, the overhead of types is negligible compared to any processing of the deprecations themselves.

WDYT?

All points can be discussed separately if needed of course. I'm personally fine with merging the PR as is, with all 3 changes.

Commits
-------

0032b2a289 [Contracts/Deprecation] don't use assert(), rename to trigger_deprecation()
2020-02-08 14:30:44 +01:00
Nicolas Grekas
0032b2a289 [Contracts/Deprecation] don't use assert(), rename to trigger_deprecation() 2020-02-08 14:27:18 +01:00
Fabien Potencier
3ebe15e0be minor #35646 [Validator] Added the missing Mongolian translations (erheme318)
This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] Added the missing Mongolian translations

https://github.com/symfony/symfony/issues/30175

Added the missing translations for the Mongolian ("mn") locale.

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #30175
| License       | MIT
| Doc PR        |

Commits
-------

365f4d76bd [Validator] Added the missing Mongolian translations
2020-02-08 11:44:41 +01:00
Erkhembayar Gantulga
365f4d76bd [Validator] Added the missing Mongolian translations
https://github.com/symfony/symfony/issues/30175

Added the missing translations for the Mongolian ("mn") locale.
2020-02-08 18:24:04 +08:00
Fabien Potencier
916ff106c5 feature #33456 [MonologBridge] Add Mailer handler (BoShurik)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[MonologBridge] Add Mailer handler

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #33209   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | - <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - 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 4.4.
 - Legacy code removals go to the master branch.
-->

Commits
-------

5b7393b823 Add monolog mailer handler
2020-02-08 09:01:20 +01:00
Fabien Potencier
4bc1ea21b9 feature #35384 [Messenger] Add receiving of old pending messages (redis) (toooni)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Messenger] Add receiving of old pending messages (redis)

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/12976

This PR makes it possible for the redis transport to get abandoned messages from not running/idle consumers by using `XPENDING` and `XCLAIM`.
Usually it would be best to let the claiming of pending messages be handled by a separate command. Since the messenger component's commands are fixed, we do need to set a `claimTimeout`. The `claimTimeout` defines how long an idle message should be left alone until it will get claimed by the current consumer (Must be a value higher than the longest running handling time of a message or else the message will be handled twice).
Using this solution makes the remarks (https://github.com/symfony/symfony-docs/pull/11869#pullrequestreview-257483666) regarding not being able to use the hostname as consumer name obsolete. I would even recommend the hostname as the consumer name.

**Questions**

- [x] Which value should we use as default `claimTimeout`?
- [x] How should the `claimTimeout` be configured?
- [x] Feature or Bugfix?

I will create a docs PR and a PR for the other branches as soon as the questions are resolved.

Commits
-------

9cb6fdfabb Implemted receiving of old pending messages
2020-02-08 08:48:00 +01:00
Fabien Potencier
32ce188b68 feature #34456 [Validator] Add a constraint to sequentially validate a set of constraints (ogizanagi)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Validator] Add a constraint to sequentially validate a set of constraints

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | N/A <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | Todo

Follows https://github.com/symfony/symfony/issues/20017#issuecomment-331276007 given some feedbacks about the suggested feature.

```php
/**
 * @var string
 *
 * @Assert\Sequentially({
 *     @Assert\Type("string"),
 *     @Assert\Length(min="4"),
 *     @Assert\Regex("[a-z]"),
 *     @SomeCustomConstraintWithHeavyExternalCalls(),
 * })
 */
public $foo;
```

This new `Sequentially` constraint solves - with less power but better DX - some of the use-cases of the `GroupSequence` feature, allowing to interrupt the validation of some constraints if a previous one in the list failed before. Constraints are validated in given order, and the first violation raised will prevent other constraint validators to be executed.
It can either prevent unexpected type exceptions thrown by further constraints or heavy & unnecessary calls to a database or external services if the value to validate already doesn't match some of the basic requirements.

Commits
-------

dfd9038d28 [Validator] Add a constraint to sequentially validate a set of constraints
2020-02-08 08:14:30 +01:00
Fabien Potencier
f53ea3d04f feature #34334 [Validator] Allow to define a reusable set of constraints (ogizanagi)
This PR was squashed before being merged into the 5.1-dev branch (closes #34334).

Discussion
----------

[Validator] Allow to define a reusable set of constraints

| Q             | A
| ------------- | ---
| Branch?       | 5.1 <!-- see below -->
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | N/A <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | TODO

The goal of this feature is to simplify writing a set of validation constraints to be reused consistently across the application. Which is especially useful with DTOs, as a same set of constraints can be used in different places.

For instance, given multiple DTOs containing the new user password in for different use-cases (register, forgot pwd, change pwd), the same rules apply on the property. Hence with this PR, you can write a single constraint class to be reused:

```php
/**
 * @Annotation
 */
class MatchesPasswordRequirements extends Compound
{
    protected function getConstraints(array $options): array
    {
        return [
            new NotBlank(),
            new Type('string'),
            new Length(['min' => 12]),
            new NotCompromisedPassword(),
        ];
    }
}
```

I'm open to better naming and ways to expose the options to the `Compound::getConstraints` method, so options can be forwarded to the nested constraints for most specific use-cases.

Commits
-------

8f1b0dfdb7 [Validator] Allow to define a reusable set of constraints
2020-02-08 08:09:39 +01:00
Maxime Steinhausser
8f1b0dfdb7 [Validator] Allow to define a reusable set of constraints 2020-02-08 08:09:33 +01:00
Fabien Potencier
2d89ed1f26 bug #35641 [Process] throw when PhpProcess::fromShellCommandLine() is used (Guikingone)
This PR was merged into the 4.4 branch.

Discussion
----------

[Process] throw when PhpProcess::fromShellCommandLine() is used

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35637
| License       | MIT
| Doc PR        | None

Close #35638

Final PR (rebased and tests added)

Commits
-------

7f6d71c2a3 refactor(Process): fromShellCommandLine
2020-02-08 08:06:43 +01:00
Fabien Potencier
f4490a6c65 feature #35642 [HttpFoundation] Make dependency on Mime component optional (atailouloute)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[HttpFoundation] Make dependency on Mime component optional

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Make the Mime component dependency optional

/cc @nicolas-grekas

Commits
-------

11cef32ff7 [HttpFoundation] Make dependency on Mime component optional
2020-02-08 08:05:09 +01:00
Fabien Potencier
138439adc6 bug #35645 [ErrorHandler] Never throw on warnings triggered by assert() and set assert.exception=1 in Debug::enable() (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] Never throw on warnings triggered by assert() and set assert.exception=1 in Debug::enable()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Because we don't use `assert()`, this is something we completely overlooked, but warnings triggered should not throw as there is already a dedicated exception mode when using `assert()`.

This turns this exception mode to 1 in debug mode and logs the assert() warnings in prod.

Commits
-------

f18ef6ca08 [ErrorHandler] Never throw on warnings triggered by assert() and set assert.exception=1 in Debug::enable()
2020-02-08 08:03:35 +01:00
Fabien Potencier
4253251278 feature #35635 [HttpKernel] Make ErrorListener unaware of the event dispatcher (derrabus)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[HttpKernel] Make ErrorListener unaware of the event dispatcher

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A

Under certain circumstances, HttpKernel's `ErrorListener` class might dynamically register and unregister a listener with the dispatcher. If our goal is to make the dispatcher immutable, that specific behavior would be in our way. Also, #34988 would break this workflow.

This PR provides an alternative. The listener is always registered, but I'm using the request to piggyback a flag that activates/deactivates the listener.

Commits
-------

a9d1dede44 [HttpKernel] Make ErrorListener unaware of the event dispatcher.
2020-02-08 08:02:19 +01:00
Nicolas Grekas
f18ef6ca08 [ErrorHandler] Never throw on warnings triggered by assert() and set assert.exception=1 in Debug::enable() 2020-02-08 00:29:13 +01:00
Ahmed TAILOULOUTE
11cef32ff7 [HttpFoundation] Make dependency on Mime component optional 2020-02-07 21:28:17 +01:00
Loulier Guillaume
7f6d71c2a3
refactor(Process): fromShellCommandLine 2020-02-07 21:06:44 +01:00
Fabien Potencier
cb424805f8 bug #35633 [Mailer] Do not ping the SMTP server before sending every message (micheh)
This PR was squashed before being merged into the 4.4 branch (closes #35633).

Discussion
----------

[Mailer] Do not ping the SMTP server before sending every message

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35515
| License       | MIT

This pull request changes the SMTP transport to only ping the server if the last message was sent more than a specified number of seconds ago (instead of pinging the server before every message). By default, it will ping the server if 100 or more seconds since the last message have passed.

This should make sending emails with the SMTP transport more robust with many emails, as SMTP servers will often drop the connection if too many non-mail commands are sent (like pinging the server with NOOP commands).

Commits
-------

28178108d3 [Mailer] Do not ping the SMTP server before sending every message
2020-02-07 17:56:44 +01:00
Michel Hunziker
28178108d3 [Mailer] Do not ping the SMTP server before sending every message 2020-02-07 17:56:37 +01:00
Maxime Steinhausser
dfd9038d28 [Validator] Add a constraint to sequentially validate a set of constraints 2020-02-07 17:16:17 +01:00
Nicolas Grekas
83a53a5edf [VarDumper] fix transient failure 2020-02-07 16:06:29 +01:00
Alexander M. Turek
a9d1dede44 [HttpKernel] Make ErrorListener unaware of the event dispatcher. 2020-02-07 15:36:38 +01:00
Nicolas Grekas
cd5c1d6361 minor #34058 [YAML] Improve performance of YAML parser (NamelessCoder)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[YAML] Improve performance of YAML parser

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

Optimise various methods and conditions to use best
performing alternatives where possible. Roughly:

* Uses methods that do not copy memory, e.g. strncmp
  as alternative for strpos matching beginning of string.
* Switches order of some conditions to put the cheapest
  checks first in order.
* Checks input before calling trim() - despite the function
  returning the same string as input, it still costs memory
  and introduces unnecessary overhead.
* Extracts variables for repeated identical function calls.
* Uses negative substring offsets instead of strlen + substr.
* Replaces single-char substr usages with substring access.

Profiling method
-----------------

Profiled using a custom script which splits and parses all provided `fixture` files from the YAML component's test directory, then profiled this through Blackfire and identified frequent method calls.

Refactoring strategy
--------------------

Most important change: switching strpos to strncmp to avoid scanning a full (and potentially very long) YAML line for occurrence of a substring.

Whenever possible, I've gone for PHP methods that do not copy memory and replaced some instances of function calls which could be replaced with substring access.

In methods which are called frequently I've gone for guard clauses to prevent further processing if a YAML line is, for example, empty. Such as avoiding trim() on already empty lines.

Profiling results
----------------

A Blackfire profiling delta can be seen on https://blackfire.io/profiles/compare/90fd3005-8b9f-4534-8bd8-1e66832bf247/graph. Taken with 200 samples which render every YAML fixture from the component's test dir.

Commits
-------

7a7c9665da [YAML] Improve performance of YAML parser
2020-02-07 15:18:18 +01:00
Claus Due
7a7c9665da [YAML] Improve performance of YAML parser
Optimise various methods and conditions to use best
performing alternatives where possible. Roughly:

* Uses methods that do not copy memory, e.g. strncmp
  as alternative for strpos matching beginning of string.
* Switches order of some conditions to put the cheapest
  checks first in order.
* Checks input before calling trim() - despite the function
  returning the same string as input, it still costs memory
  and introduces unnecessary overhead.
* Extracts variables for repeated identical function calls.
* Uses negative substring offsets instead of strlen + substr.
* Replaces single-char substr usages with substring access.
2020-02-07 15:17:29 +01:00
Nicolas Grekas
ecf37ddcbf Merge branch '5.0'
* 5.0:
  Fix typo
2020-02-07 11:18:17 +01:00
Nicolas Grekas
73f8c962a6 Merge branch '4.4' into 5.0
* 4.4:
  Fix typo
2020-02-07 11:18:13 +01:00
Nicolas Grekas
05663c338f Fix typo 2020-02-07 11:18:08 +01:00
Nicolas Grekas
c37acb9952 Merge branch '5.0'
* 5.0:
  [travis] fix patching return types of symfony/contracts
  [FrameworkBundle] fix fix fix deps=low
  [FrameworkBundle] fix fix deps=low
  [FrameworkBundle] fix deps=low
2020-02-07 10:38:36 +01:00
Nicolas Grekas
ab46117272 Merge branch '4.4' into 5.0
* 4.4:
  [travis] fix patching return types of symfony/contracts
  [FrameworkBundle] fix fix fix deps=low
  [FrameworkBundle] fix fix deps=low
  [FrameworkBundle] fix deps=low
2020-02-07 10:38:28 +01:00
Nicolas Grekas
3bfd4ed237 minor #35630 [travis] fix patching return types of symfony/contracts (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[travis] fix patching return types of symfony/contracts

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Fixing failing builds like https://travis-ci.org/symfony/symfony/jobs/647233182

Commits
-------

076a2a0a71 [travis] fix patching return types of symfony/contracts
2020-02-07 10:38:19 +01:00
Nicolas Grekas
076a2a0a71 [travis] fix patching return types of symfony/contracts 2020-02-07 10:34:30 +01:00
Nicolas Grekas
ddc00ed29d Merge branch '3.4' into 4.4
* 3.4:
  [FrameworkBundle] fix fix fix deps=low
  [FrameworkBundle] fix fix deps=low
  [FrameworkBundle] fix deps=low
2020-02-07 10:14:27 +01:00
Nicolas Grekas
47f467a4cc [FrameworkBundle] fix fix fix deps=low 2020-02-07 10:13:59 +01:00
Nicolas Grekas
16dd360511 [FrameworkBundle] fix fix deps=low 2020-02-07 10:12:20 +01:00
Nicolas Grekas
02e5d73116 [FrameworkBundle] fix deps=low 2020-02-07 10:11:45 +01:00
Nicolas Grekas
8b121a2c4d Merge branch '5.0'
* 5.0:
  [FrameworkBundle] fix "samesite" in XSD
  [Console] Consider STDIN interactive
  Update UserPasswordEncoderCommand.php
  [HttpFoundation][FrameworkBundle] fix support for samesite in session cookies
  [DoctrineBridge] Fixed submitting ids with query limit or offset
2020-02-07 09:49:04 +01:00
Nicolas Grekas
2f836ac8b2 Merge branch '4.4' into 5.0
* 4.4:
  [FrameworkBundle] fix "samesite" in XSD
  [Console] Consider STDIN interactive
  Update UserPasswordEncoderCommand.php
  [HttpFoundation][FrameworkBundle] fix support for samesite in session cookies
  [DoctrineBridge] Fixed submitting ids with query limit or offset
2020-02-07 09:48:51 +01:00
Nicolas Grekas
df41ca5b71 Merge branch '3.4' into 4.4
* 3.4:
  [FrameworkBundle] fix "samesite" in XSD
  Update UserPasswordEncoderCommand.php
  [HttpFoundation][FrameworkBundle] fix support for samesite in session cookies
  [DoctrineBridge] Fixed submitting ids with query limit or offset
2020-02-07 09:47:19 +01:00
Nicolas Grekas
abac71b0a4 [FrameworkBundle] fix "samesite" in XSD 2020-02-07 09:43:36 +01:00
Nicolas Grekas
ca570d31b8 feature #35019 [Cache] add SodiumMarshaller (atailouloute)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Cache] add SodiumMarshaller

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Add `SodiumMarshaller` to encrypt cache values

To use the `SodiumMarshaller` we can decorate the `cache.default_marshaller`:

```yaml
Symfony\Component\Cache\Marshaller\SodiumMarshaller:
    decorates: cache.default_marshaller
    arguments:
        - ['%env(CACHE_DECRYPTION_KEY)%', '%env(OLD_CACHE_DECRYPTION_KEY)%']
        - '@Symfony\Component\Cache\Marshaller\SodiumMarshaller.inner'
```

The first provided key is used to encrypt and decrypt cached values.

In order to allow rotating keys, more keys can be provided - they will be used only to decrypt values.

/cc @nicolas-grekas

Commits
-------

540d7eb174 [Cache] add SodiumMarshaller
2020-02-07 09:34:21 +01:00
Nicolas Grekas
53fcf7241a bug #33897 [Console] Consider STDIN interactive (ostrolucky)
This PR was submitted for the master branch but it was merged into the 4.4 branch instead.

Discussion
----------

[Console] Consider STDIN interactive

| Q             | A
| ------------- | ---
| Branch?       |4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #30726, supersedes #30796
| License       | MIT
| Doc PR        | -

As demonstrated with `yes | bin/console foo` in #30726, original assumption made in #1699 was wrong. Then, #8452 was merged which solved bug #8079 -> this was a use case when application hangs with `--no-interaction` flag - nobody probably realized that application can be in "non-interactive" mode, without using this flag and not hang. Then, there was #14102 which was poor man's fix for problem caused by this. So already plenty issues this behaviour causes. Looks like a mess to me. Application should be considered non-interactive only when explicitly specified so (--no-interactive flag), otherwise it doesn't hang.

### What this change means?
It only changes one case: When doing `echo foo | bin/console bar`, `yes | bin/console bar`, `bin/console bar < foo`, etc. Redirecting stdout is not affected, as application in that case was considered interactive before too. With stdin, this opens possibility to control symfony/console based application by default via stdin, including via `proc_open`.

Additionally, not only it allows to control the input for questions, it also makes the question and answers to display on screen. So before, user had no idea what questions are happening and what answers (defaults) are being used.

### About a BC break
I'm not really aware of a valid use case this can break. Can you help find any?

1. Since symfony/console components were NOT interactive with stdin before, stdin couldn't be used to control them - so there this change breaks nothing, because it didn't make sense to pass stdin there instead of specifying -n flag.
1. If application uses internal logic where it relies on STDIN disregarding `Output::isInteractive` flag, this doesn't change anything for these either - they will keep using STDIN disregarding result of this flag.
1. What if application uses internal logic for stdin AND console components like QuestionHelper? To me, that doesn't make much sense, because with previous behaviour, such questions would result always into defaults. It might make sense in case application supports both modes - either stdin, or user supplied input and just use default answers with stdin. But I cannot figure out example of such use - what would be the case where application allows user to control something via stdin, but at the same time forbids them to set certain aspects (answers to questions given)?
1. What about `SHELL_INTERACTIVE` env variable? Only way to utilize it was to force enable interactive mode, but since it will be interactive now by default, it will do nothing and no behaviour changes.
1. Preventing stdin control was much bigger potential BC break. Despite that, it was disallowed in minor Symfony version. And as far as I can see, I saw no backlash.

Finally, this targets Symfony 5.0 to be extra sure anyways, so I think it's ok, but feel free to suggest documenting this in upgrade guide or changelog. I would even target 4.4, but chose 5.0 as it's easier to push through there.

Commits
-------

ef157d5b3f [Console] Consider STDIN interactive
2020-02-07 09:29:57 +01:00
Gabriel Ostrolucký
ef157d5b3f [Console] Consider STDIN interactive 2020-02-07 09:29:36 +01:00
Nicolas Grekas
e662cc4838 feature #35625 [String] Add the s() helper method (fancyweb)
This PR was merged into the 5.1-dev branch.

Discussion
----------

[String] Add the s() helper method

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | https://github.com/symfony/symfony/pull/35578#discussion_r374512887
| License       | MIT
| Doc PR        | -

This method will be useful in our code base, and to anyone that doesn't really understand the differences between UnicodeString and ByteString.

Commits
-------

659cdf1871 [String] Add the s() helper method
2020-02-07 09:18:56 +01:00