Commit Graph

30576 Commits

Author SHA1 Message Date
Fabien Potencier
d662b2152d feature #22306 [DI] Restrict autowired registration to "same-vendor" namespaces (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Restrict autowired registration to "same-vendor" namespaces

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Following #22295, it came to me that I've already been bitten hard by the auto-registration we decided to keep working: when one type-hints some class in the Symfony namespace (eg `Request`), then autoregistration creates a corresponding service. You see the issue. Hard time debugging that.

By restricting autoregistration to same-vendor (=same-root-namespace), we can keep all benefits of autoregistration, while closing this DX trap.

The patch is bigger than strictly required to implement this, but contains a few related fixes and cleanups.

Commits
-------

9c53b3deb0 [DI] Restrict autowired registration to "same-vendor" namespaces
2017-04-06 07:27:53 -07:00
Nicolas Grekas
9c53b3deb0 [DI] Restrict autowired registration to "same-vendor" namespaces 2017-04-06 11:28:30 +02:00
Fabien Potencier
ab93feae3f feature #22295 [BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | yes - compile time only
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

(patch best reviewed [ignoring whitespaces](https://github.com/symfony/symfony/pull/22295/files?w=1).)

"By-id" autowiring, as introduced in #22060 is free from all the issues that "by-type" autowiring has:
- it has no magic and requires explicit type<>id matching (*vs* using reflection on all services to cherry-pick *the* one that matches some type-hint *at that time*, which is fragile)
- it is free from any ambiguities (*vs* the Damocles' sword of breaking config just by enabling some unrelated bundle)
- it is easily introspected: just look at DI config files (*vs* inspecting the type-hierarchy of all services + their type-hints)
- ~~it is side-effect free, thus plain predictable (*vs* auto-registration of discovered types as services)~~
- it plays nice with deprecated services or classes (see #22282)
- *etc.*

Another consideration is that any "by-type" autowired configuration is either broken (because of future ambiguities) - or equivalent to a "by-id" configuration (because resolving ambiguities *means* adding explicit type<>id mappings.) For theoreticians, we could say that "by-id" autowiring is the asymptotic limit of "by-type" autowiring :-)

For all these reasons - and also because it reduces the complexity of the code base - I propose to change the behavior and only support "by-id" autowiring in 3.3. This will break some configurations relying on "by-type" autowiring. Yet the break will only happen at compile-time, which means this won't *silently* break any apps. For all core Symfony services, they will work out of the box thanks to #22098 *et al.* For the remaining services, fixing ones config should be pretty straightforward: just follow the suggestions provided by the exception messages. If they are fine to you, you'll end up with the exact same config in the end. And maybe you'll spot issues that were hidden previously.

Commits
-------

cc5e582dcf [BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services
2017-04-05 16:31:59 -07:00
Fabien Potencier
d33c0ee4d1 feature #20951 Redesigned the exception pages (javiereguiluz)
This PR was squashed before being merged into the 3.3-dev branch (closes #20951).

Discussion
----------

Redesigned the exception pages

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20620
| License       | MIT
| Doc PR        | -

Here are some before/after screenshots:

| Before | After
| --- | ---
| ![exception-before-1](https://cloud.githubusercontent.com/assets/73419/21258148/f8fd6482-c37b-11e6-9efe-1bcf7b323c0f.png) | ![exception-after-1](https://cloud.githubusercontent.com/assets/73419/21258156/016059cc-c37c-11e6-8bab-80456189d614.png)

| Before | After
| --- | ---
| ![exception-before-2](https://cloud.githubusercontent.com/assets/73419/21258171/11198a46-c37c-11e6-8a28-ae45e19e3eaf.png) | ![exception-after-2](https://cloud.githubusercontent.com/assets/73419/21258223/4cb9ac66-c37c-11e6-93db-0db2c204dc0b.png)

| Before | After
| --- | ---
| ![exception-before-3](https://cloud.githubusercontent.com/assets/73419/21258239/5a0747ac-c37c-11e6-923e-564322e862a6.png) | ![exception-after-3](https://cloud.githubusercontent.com/assets/73419/21258246/62ad8b00-c37c-11e6-8838-3c1824c18287.png)

---

And here is the new design in action because everything is very dynamic and you can click anywhere to reveal/collapse things:

![exception-in-action](https://cloud.githubusercontent.com/assets/73419/21258261/7445f140-c37c-11e6-9318-f3807fe38689.gif)

Commits
-------

9d0c26377f Redesigned the exception pages
2017-04-05 16:04:34 -07:00
Javier Eguiluz
9d0c26377f Redesigned the exception pages 2017-04-05 16:04:30 -07:00
Nicolas Grekas
cc5e582dcf [BC BREAK][DI] Always autowire "by id" instead of using reflection against all existing services 2017-04-05 23:48:42 +02:00
Nicolas Grekas
12bb392a39 Merge branch '3.2'
* 3.2:
  move provider after test
  update dataProvider function name
  cast substr result to string and remove empty function use
  rename dataset provider
  Add a test to prevent future regressions
  Switch to `empty` native function to check emptiness
  remove non relevant test case
  Switch to `is_string` native method
  Remove unnecessary parentheses
  Add a test case to prevent future regressions
  Move empty condition in return statement
  Use LF line separator
  fix coding standard to comply with fabbot
  Remove malformed EmailValidatorTest + Update UrlValidator test
  Add empty check on host in other methods + add unit tests
  [Validator] Allow checkMX() to return false when $host is empty
  [DI] Prevent AutowirePass from triggering irrelevant deprecations
  [DI] Fix the xml schema
  [Translation] avoid creating cache files for fallback locales.
2017-04-05 23:43:54 +02:00
Nicolas Grekas
32f264f3c8 Merge branch '2.8' into 3.2
* 2.8:
  move provider after test
  update dataProvider function name
  cast substr result to string and remove empty function use
  rename dataset provider
  Add a test to prevent future regressions
  Switch to `empty` native function to check emptiness
  remove non relevant test case
  Switch to `is_string` native method
  Remove unnecessary parentheses
  Add a test case to prevent future regressions
  Move empty condition in return statement
  Use LF line separator
  fix coding standard to comply with fabbot
  Remove malformed EmailValidatorTest + Update UrlValidator test
  Add empty check on host in other methods + add unit tests
  [Validator] Allow checkMX() to return false when $host is empty
  [DI] Prevent AutowirePass from triggering irrelevant deprecations
  [DI] Fix the xml schema
  [Translation] avoid creating cache files for fallback locales.
2017-04-05 23:38:45 +02:00
Nicolas Grekas
8d0cfa444a Merge branch '2.7' into 2.8
* 2.7:
  move provider after test
  update dataProvider function name
  cast substr result to string and remove empty function use
  rename dataset provider
  Add a test to prevent future regressions
  Switch to `empty` native function to check emptiness
  remove non relevant test case
  Switch to `is_string` native method
  Remove unnecessary parentheses
  Add a test case to prevent future regressions
  Move empty condition in return statement
  Use LF line separator
  fix coding standard to comply with fabbot
  Remove malformed EmailValidatorTest + Update UrlValidator test
  Add empty check on host in other methods + add unit tests
  [Validator] Allow checkMX() to return false when $host is empty
  [DI] Fix the xml schema
  [Translation] avoid creating cache files for fallback locales.
2017-04-05 23:34:00 +02:00
Fabien Potencier
457174dad9 feature #21919 [Form] Deprecated usage of "choices" option in sub types (HeahDude)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Form] Deprecated usage of "choices" option in sub types

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | ~

Follows #21880 and the discussion in #20771.

Commits
-------

b5b56fcbac [Form] Deprecated usage of "choices" option in sub types
2017-04-05 11:14:26 -07:00
Fabien Potencier
2adfb375c6 bug #22109 [Validator] check for empty host when calling checkdnsrr() (apetitpa)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #22109).

Discussion
----------

[Validator] check for empty host when calling checkdnsrr()

| Q | A |
| --- | --- |
| Branch? | master|
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #22106 |
| License | MIT |
| Doc PR | n/a |

This should fix the email validator issue

Commits
-------

7104c4e849 move provider after test
c07fb416ff update dataProvider function name
1825d0f2ae cast substr result to string and remove empty function use
894127bf09 rename dataset provider
d973eb1f7d Add a test to prevent future regressions
6f24b05467 Switch to `empty` native function to check emptiness
f390f29173 remove non relevant test case
91b665c12a Switch to `is_string` native method
6071ff6c8f Remove unnecessary parentheses
9753a2773e Add a test case to prevent future regressions
4fcb24bacb Move empty condition in return statement
a090ef855a Use LF line separator
60392fdd43 fix coding standard to comply with fabbot
197d19f34c Remove malformed EmailValidatorTest + Update UrlValidator test
6b0702e52a Add empty check on host in other methods + add unit tests
6dd023f255 [Validator] Allow checkMX() to return false when $host is empty
2017-04-05 11:10:59 -07:00
apetitpa
7104c4e849 move provider after test 2017-04-05 11:10:47 -07:00
apetitpa
c07fb416ff update dataProvider function name 2017-04-05 11:10:47 -07:00
apetitpa
1825d0f2ae cast substr result to string and remove empty function use 2017-04-05 11:10:47 -07:00
apetitpa
894127bf09 rename dataset provider 2017-04-05 11:10:47 -07:00
apetitpa
d973eb1f7d Add a test to prevent future regressions 2017-04-05 11:10:47 -07:00
apetitpa
6f24b05467 Switch to empty native function to check emptiness
Switch to `empty` because depending on the PHP version, substr returns '' or false
2017-04-05 11:10:47 -07:00
apetitpa
f390f29173 remove non relevant test case 2017-04-05 11:10:47 -07:00
apetitpa
91b665c12a Switch to is_string native method 2017-04-05 11:10:46 -07:00
apetitpa
6071ff6c8f Remove unnecessary parentheses 2017-04-05 11:10:32 -07:00
apetitpa
9753a2773e Add a test case to prevent future regressions 2017-04-05 11:10:32 -07:00
apetitpa
4fcb24bacb Move empty condition in return statement 2017-04-05 11:10:32 -07:00
apetitpa
a090ef855a Use LF line separator 2017-04-05 11:10:32 -07:00
apetitpa
60392fdd43 fix coding standard to comply with fabbot 2017-04-05 11:10:32 -07:00
apetitpa
197d19f34c Remove malformed EmailValidatorTest + Update UrlValidator test
Remove malformed EmailValidatorTest + Update UrlValidator test
2017-04-05 11:10:32 -07:00
apetitpa
6b0702e52a Add empty check on host in other methods + add unit tests
Add empty on host in other methods where checkdnsrr is called and add unit tests to prevent future regressions
2017-04-05 11:10:31 -07:00
apetitpa
6dd023f255 [Validator] Allow checkMX() to return false when $host is empty
| Q | A |
| --- | --- |
| Branch? | master |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #22106 |
| License | MIT |
| Doc PR | n/a |
2017-04-05 11:10:12 -07:00
Fabien Potencier
933835c13b bug #22280 [DI] Fix the xml schema (GuilhemN)
This PR was merged into the 2.7 branch.

Discussion
----------

[DI] Fix the xml schema

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

f2ef1eecef [DI] Fix the xml schema
2017-04-05 08:21:50 -07:00
Fabien Potencier
937045c839 feature #22274 [Yaml] report deprecations when linting YAML files (xabbuh)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Yaml] report deprecations when linting YAML files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

In a project I frequently discovered usages of deprecated YAML formats. I first wanted to set up a build step that would lint all YAML files found in that project to be able to report it inside the CI. While doing so I noticed that the lint command was ignoring all deprecations after all. I suggest that catch all deprecations triggered by the YAML components and turn them into reported errors here. If we think that this could be seen as misbehaviour as the Symfony YAML parser is still able to handle these files properly, we could think about adding an additional option to the command that would turn on the deprecation handling.

Commits
-------

9b4206ff73 report deprecations when linting YAML files
2017-04-05 08:20:10 -07:00
Fabien Potencier
d45d40d732 feature #22286 [DI/Yaml] Remove @experimental flag from "instanceof" and "prototype" (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI/Yaml] Remove `@experimental` flag from "instanceof" and "prototype"

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

We don't need this flag on these features: the implementation is stable, and regular deprecations should be the way to go in the event where we decide to remove this later on.

That would leave only one single `@experimental` feature in 3.3: `CacheItem::getPreviousTags()`, which looks legitimate to me (since this method is aiming at interop).

Commits
-------

e8723df28a [DI/Yaml] Remove `@experimental` flag from "instanceof" and "prototype"
2017-04-05 08:10:17 -07:00
Fabien Potencier
2a40b6fbfd bug #22300 [WebProfiler] Fix race condition in fast Ajax requests (curry684)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[WebProfiler] Fix race condition in fast Ajax requests

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22297
| License       | MIT

Patch `startAjaxRequest` and `finishAjaxRequest` functions to absolute noop in case the debug toolbar itself is not loaded yet, and spool historic requests after the toolbar is loaded.

Commits
-------

538a59254f [WebProfiler] Fix race condition in fast Ajax requests
2017-04-05 08:08:32 -07:00
Fabien Potencier
54495b2bd6 feature #22181 [Console] Allow to catch CommandNotFoundException (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Console] Allow to catch CommandNotFoundException

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/22144#issuecomment-289200937
| License       | MIT
| Doc PR        | n/a

Basically reverts #22144, making the command argument optional in console.error event instead, so that `CommandNotFoundException` can be handled as any other console error.

Commits
-------

b21ce850e7 [Console] Allow to catch CommandNotFoundException
2017-04-05 08:05:16 -07:00
Fabien Potencier
91b025affc bug #22282 [DI] Prevent AutowirePass from triggering irrelevant deprecations (chalasr)
This PR was merged into the 2.8 branch.

Discussion
----------

[DI] Prevent AutowirePass from triggering irrelevant deprecations

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no (just a failing test case atm)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

For populating available types the AutowirePass iterates over `$container->getDefinitions()` trying to instantiate a reflection class for each definition.
Problem is that if one of these classes is deprecated, a notice is triggered due to the reflection, even if the service is actually never used.

~~Right now this only reproduces the issue with a failing test case~~, this bug (if we agree it's a bug) breaks the test suite of a bundle I maintain (see https://travis-ci.org/lexik/LexikJWTAuthenticationBundle/jobs/218275650#L262)

Solutions I can think about for now:
- ~~Skip deprecated definitions from type registering, meaning that if a service is deprecated a day, all autowired services that rely on it will suddenly be broken, also the bug would remain if the definition is not deprecated but relies on a deprecated class, not good I think~~
- Register an error handler ignoring deprecations during the type registering process (`AutowirePass#populateAvailableType()`), ~~works but makes my test suite say `THE ERROR HANDLER HAS CHANGED`. I'll push my try as a 2nd commit.~~

Thoughts?

Commits
-------

77927f4b33 [DI] Prevent AutowirePass from triggering irrelevant deprecations
2017-04-05 08:02:21 -07:00
Fabien Potencier
a2003579e9 bug #22255 [Translation] avoid creating cache files for fallback locales. (aitboudad)
This PR was merged into the 2.7 branch.

Discussion
----------

[Translation] avoid creating cache files for fallback locales.

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21163
| License       | MIT
| Doc PR        | ~

Commits
-------

22425b2692 [Translation] avoid creating cache files for fallback locales.
2017-04-05 07:56:27 -07:00
Robin Chalas
77927f4b33 [DI] Prevent AutowirePass from triggering irrelevant deprecations 2017-04-05 16:41:09 +02:00
Christian Flothmann
9b4206ff73 report deprecations when linting YAML files 2017-04-05 16:34:46 +02:00
Fabien Potencier
b65ebc7424 feature #22296 Bump monolog to 1.19 and use the agent regex const from parent (redthor)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Bump monolog to 1.19 and use the agent regex const from parent

See #22264

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | refer to #22264
| License       | MIT
| Doc PR        |

Bump monolog and use const from parent. See https://github.com/symfony/symfony/issues/22264#issuecomment-291524038

I went for `static` instead of `self` in case anyone wanted to easily override just the agent string.

Commits
-------

69f9586fd5 Bump monolog to 1.19 and use the agent regex const from parent, see #22264
2017-04-05 06:53:23 -07:00
Fabien Potencier
3aeac5aa3f Merge branch '3.2'
* 3.2:
  bumped Symfony version to 3.2.8
  updated VERSION for 3.2.7
  updated CHANGELOG for 3.2.7
  Fixes #22264 - add support for Chrome headless, see also Seldaek/monolog#966
  [Workflow] update documentation URL in readme
  bumped Symfony version to 2.8.20
  updated VERSION for 2.8.19
  updated CHANGELOG for 2.8.19
  Dont call sprintf() when no placeholders are used
2017-04-05 06:44:55 -07:00
Fabien Potencier
f53e81dd6a Merge branch '2.8' into 3.2
* 2.8:
  Fixes #22264 - add support for Chrome headless, see also Seldaek/monolog#966
  bumped Symfony version to 2.8.20
  updated VERSION for 2.8.19
  updated CHANGELOG for 2.8.19
  Dont call sprintf() when no placeholders are used
2017-04-05 06:44:24 -07:00
Fabien Potencier
f92ada80f4 Merge branch '2.7' into 2.8
* 2.7:
  Fixes #22264 - add support for Chrome headless, see also Seldaek/monolog#966
  Dont call sprintf() when no placeholders are used
2017-04-05 06:42:13 -07:00
Niels Keurentjes
538a59254f [WebProfiler] Fix race condition in fast Ajax requests
Patch startAjaxRequest and finishAjaxRequest functions to absolute noop
in case the debug toolbar itself is not loaded yet, and spool historic
requests after the toolbar is loaded.

Fixes #22297
2017-04-05 15:42:05 +02:00
Fabien Potencier
cb49907570 bug #22292 Fixes #22264 - add support for Chrome headless (redthor)
This PR was merged into the 2.7 branch.

Discussion
----------

Fixes #22264 - add support for Chrome headless

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22264
| License       | MIT
| Doc PR        |

Commits
-------

a03dbd2cca Fixes #22264 - add support for Chrome headless, see also Seldaek/monolog#966
2017-04-05 06:41:26 -07:00
Fabien Potencier
958b0aeffc bug #22279 [DI] Fix anonymous factories/configurators support (GuilhemN)
This PR was squashed before being merged into the 3.3-dev branch (closes #22279).

Discussion
----------

[DI] Fix anonymous factories/configurators support

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/21999#discussion_r106019873
| License       | MIT
| Doc PR        |

Using prototypes / instanceof conditionals, anonymous factories are inlined using `Definition`, so a new instance will be created for every service created from the prototype / conditional which is inconsistent with the way other anonymous services are managed.

Commits
-------

dda43ed8ce [DI] Fix anonymous factories/configurators support
2017-04-05 06:16:31 -07:00
Guilhem Niot
dda43ed8ce [DI] Fix anonymous factories/configurators support 2017-04-05 06:16:28 -07:00
Fabien Potencier
757e5f7f7c bumped Symfony version to 3.2.8 2017-04-05 06:13:01 -07:00
Douglas Reith
69f9586fd5 Bump monolog to 1.19 and use the agent regex const from parent, see #22264 2017-04-05 13:03:25 +00:00
Fabien Potencier
1631040ea8 Merge pull request #22293 from fabpot/release-3.2.7
released v3.2.7
2017-04-05 05:52:29 -07:00
Fabien Potencier
98313d4c7b updated VERSION for 3.2.7 2017-04-05 05:52:03 -07:00
Fabien Potencier
1c18f34230 updated CHANGELOG for 3.2.7 2017-04-05 05:51:48 -07:00
Douglas Reith
a03dbd2cca Fixes #22264 - add support for Chrome headless, see also Seldaek/monolog#966 2017-04-05 12:36:22 +00:00