Commit Graph

30506 Commits

Author SHA1 Message Date
Fabien Potencier
0a17358abf feature #19887 Sort alternatives alphabetically when a command is not found (javiereguiluz)
This PR was squashed before being merged into the 3.3-dev branch (closes #19887).

Discussion
----------

Sort alternatives alphabetically when a command is not found

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

Commits
-------

ba6c9464ea Sort commands like a human would do
f04b1bd72f Sort alternatives alphabetically when a command is not found
2017-03-22 14:10:51 -07:00
Roland Franssen
0728fb91b8 typo 2017-03-22 22:08:21 +01:00
Roland Franssen
036b0414d6 Minor PR fixes 2017-03-22 22:04:16 +01:00
Fabien Potencier
59dd7521a7 feature #20851 [Cache] Add CacheItem::getPreviousTags() (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Cache] Add CacheItem::getPreviousTags()

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

As discussed in #19728

Commits
-------

da354660e0 [Cache] Add CacheItem::getPreviousTags()
2017-03-22 14:02:20 -07:00
Roland Franssen
171c6d100e [WebProfilerBundle] Improved cookie traffic 2017-03-22 21:55:42 +01:00
Robin Chalas
0b741da343 Move AddValidatorInitializersrPass & AddConstraintValidatorsPass to the Validator 2017-03-22 21:51:09 +01:00
Fabien Potencier
9761b44aa4 bug #22034 [Security] json auth listener should not produce a 500 response on bad request format (ogizanagi)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Security] json auth listener should not produce a 500 response on bad request format

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

To me, it looks wrong to simply throw a `BadCredentialsException` in the wild, which produces a 500 (unless an entrypoint handles it, which you probably don't have on a json login firewall). There isn't any server error, the client request originated the error due to a wrong format.

Instead, the listener should give a chance to the failure handler to resolve it, and return a proper 4XX response. (BTW, the `UsernamePasswordFormAuthenticationListener` also throws a similar `BadCredentialsException` on a too long submitted username, which is caught and forwarded to the failure handler)

Better diff: https://github.com/symfony/symfony/pull/22034/files?w=1

BTW, should we have another exception type like `BadCredentialsFormatException` or whatever in order to distinct a proper `BadCredentialsException` from a format issue in a failure listener?

Commits
-------

cb175a41c3 [Security] json auth listener should not produce a 500 response on bad request format
2017-03-22 13:49:06 -07:00
Fabien Potencier
3aa7658399 bug #22022 [Validator] fix URL validator to detect non supported chars according to RFC 3986 (e-moe)
This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes #22022).

Discussion
----------

[Validator] fix URL validator to detect non supported chars according to RFC 3986

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

Commits
-------

3599c476bf [Validator] fix URL validator to detect non supported chars according to RFC 3986
2017-03-22 13:42:35 -07:00
Nikolay Labinskiy
3599c476bf [Validator] fix URL validator to detect non supported chars according to RFC 3986 2017-03-22 13:42:34 -07:00
Fabien Potencier
f29664893d Merge branch '2.8' into 3.2
* 2.8:
  Fixed pathinfo calculation for requests starting with a question mark.
  [Security] simplify the SwitchUserListenerTest
2017-03-22 13:39:24 -07:00
Fabien Potencier
89bb89538b Merge branch '2.7' into 2.8
* 2.7:
  Fixed pathinfo calculation for requests starting with a question mark.
  [Security] simplify the SwitchUserListenerTest
2017-03-22 13:39:14 -07:00
Fabien Potencier
2240ecfa14 minor #22049 [Security] simplify the SwitchUserListenerTest (xabbuh)
This PR was merged into the 2.7 branch.

Discussion
----------

[Security] simplify the SwitchUserListenerTest

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

While working on #22048 I noticed that the `SwitchUserListenerTest` was more complicated than necessary by mocking a lot of stuff that didn't need to be mocked.

Commits
-------

923bbdbf9f [Security] simplify the SwitchUserListenerTest
2017-03-22 13:38:16 -07:00
Fabien Potencier
4599afef86 minor #20885 [Console] Option to disable stty (johmue)
This PR was squashed before being merged into the 3.3-dev branch (closes #20885).

Discussion
----------

[Console] Option to disable stty

| Q             | A
| ------------- | ---
| Branch?       |
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   |
| Fixed tickets |
| License       | MIT
| Doc PR        | reference to the documentation PR, if any

Shall fix problems in Windows based environments if e.g. git is installed and stty is therefore found but writes only cryptic rubbish into the cmd. In the case of console questions it is also possible that input can't be read properly by console component.

Commits
-------

a189a6c52e [Console] Option to disable stty
2017-03-22 13:36:10 -07:00
Johannes Mueller
a189a6c52e [Console] Option to disable stty 2017-03-22 13:36:08 -07:00
Nicolas Grekas
9c6e672780 [FrameworkBundle] Add new "controller.service_arguments" tag to inject services into actions 2017-03-22 21:34:42 +01:00
Fabien Potencier
343490c201 feature #21830 [HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it

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

Follow up of #18688

PR adds a second `$trustedHeaderSet` argument to `Request::setTrustedProxies()`, can be either `Request::HEADER_FORWARDED` or `Request::HEADER_X_FORWARDED_ALL` to set which header to trust from your proxies - the idea being that without this info, one will get some `ConflictingHeadersException`, but those may be lost in the logs.

Commits
-------

d3c960493c [HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it
2017-03-22 13:33:50 -07:00
Fabien Potencier
04fcac74b1 Merge branch '2.8' into 3.2
* 2.8:
  [HttpFoundation] Fix missing handling of for/host/proto info from "Forwarded" header
  [Validator] Add object handling of invalid constraints in Composite
  [WebProfilerBundle] Remove uneeded directive in the form collector styles
  Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"
  [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST
2017-03-22 13:31:03 -07:00
Nicolas Grekas
d3c960493c [HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it 2017-03-22 21:29:40 +01:00
Fabien Potencier
8371dea4e2 bug #21849 [HttpFoundation] Fix missing handling of for/host/proto info from "Forwarded" header (nicolas-grekas)
This PR was merged into the 2.8 branch.

Discussion
----------

[HttpFoundation] Fix missing handling of for/host/proto info from "Forwarded" header

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

We're missing handling of for/host/proto info embedded in the `Forwarded` header, as eg in:
`Forwarded:  for=1.1.1.1:443, host=foo.example.com:1234, proto=https, for=2.2.2.2, host=real.example.com:8080`

Commits
-------

04caacb757 [HttpFoundation] Fix missing handling of for/host/proto info from "Forwarded" header
2017-03-22 13:28:23 -07:00
Fabien Potencier
e8653b9964 bug #21968 Fixed pathinfo calculation for requests starting with a question mark. (syzygymsu)
This PR was squashed before being merged into the 2.7 branch (closes #21968).

Discussion
----------

Fixed pathinfo calculation for requests starting with a question mark.

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

With  improper `strpos` result check calculated pathinfo for requests starting with '?' equals to request itself.
Correct pathinfo for those requests should be '/'.

Commits
-------

43297b45de Fixed pathinfo calculation for requests starting with a question mark.
2017-03-22 13:27:23 -07:00
Anton A. Sumin
43297b45de Fixed pathinfo calculation for requests starting with a question mark. 2017-03-22 13:27:21 -07:00
Fabien Potencier
3023e4b707 feature #21924 [FrameworkBundle] Allow to configure Serializer mapping paths (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Allow to configure Serializer mapping paths

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

Follows https://github.com/symfony/symfony/pull/19086 for the Serializer

Commits
-------

5446903296 [FrameworkBundle] Allow configuring serializer mapping paths
2017-03-22 13:19:32 -07:00
Nicolas Grekas
04caacb757 [HttpFoundation] Fix missing handling of for/host/proto info from "Forwarded" header 2017-03-22 21:13:53 +01:00
Fabien Potencier
5f9d941365 bug #22027 Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)" (chalasr)
This PR was merged into the 2.8 branch.

Discussion
----------

Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21953, https://github.com/symfony/symfony/issues/22050
| License       | MIT
| Doc PR        | n/a

A bit frustrated to revert this change since the BC break report lacks of information, making us unable to reproduce nor to look at improving the situation.
I'm going to re-propose this on master, covering the BC break that is identified, fixed and tested using the changes made in #21953. That will let the choice for the reporter to upgrade using the 1 required LOC.

Commits
-------

5af47c40dc Revert "bug #21841 [Console] Do not squash input changes made from console.command event (chalasr)"
2017-03-22 13:13:18 -07:00
Fabien Potencier
5dcef29531 feature #19278 [FrameworkBundle] Added about command (ro0NL)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Added about command

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any |
| License | MIT |
| Doc PR | reference to the documentation PR, if any |

![image](https://cloud.githubusercontent.com/assets/1047696/24218101/50c4ebe2-0f42-11e7-985d-b47fc8a6f520.png)

Commits
-------

2550eab43c [FrameworkBundle] Added about command
2017-03-22 13:07:01 -07:00
Fabien Potencier
e1ab80159a Merge branch '2.7' into 2.8
* 2.7:
  [Validator] Add object handling of invalid constraints in Composite
  [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST
2017-03-22 13:02:32 -07:00
Fabien Potencier
d562cacf44 bug #21846 [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST (nicolas-grekas)
This PR was merged into the 2.7 branch.

Discussion
----------

[HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST

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

The first "host" in the list provided by `X_FORWARDED_HOST` should be the one, not the last.
Already the case for "port" and "scheme".

Commits
-------

9a2b2de64f [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST
2017-03-22 13:01:02 -07:00
Roland Franssen
2550eab43c [FrameworkBundle] Added about command 2017-03-22 20:57:40 +01:00
Fabien Potencier
940c29abec minor #21926 [Routing] Optimised dumped matcher (frankdejonge)
This PR was squashed before being merged into the 3.3-dev branch (closes #21926).

Discussion
----------

[Routing] Optimised dumped matcher

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

TL;DR: I've optimised the PhpMatcherDumper output for a <del>60x</del> 4.4x performance improvement on a collection of ~800 routes by inducing cyclomatic complexity.

[EDIT] The 60x performance boost was only visible when profiling with blackfire, which is quite possibly a result of the cost of profiling playing a part. After doing some more profiling the realistic benefit of the optimisation is more likely to be in the ranges is 1.3x to 4.4x.

After the previous optimisation I began looking at how the PrefixCollection was adding its performance boost. I spotted another way to do this, which has the same theory behind it (excluding groups based on prefixes). The current implementation only groups when one prefix resides in the other. In this new implementation I've created a way to detect common prefixes, which allows for much more efficient grouping. Every time a route is added to the group it'll either merge into an existing group, merge into a new group with a route that has a common prefix, or merge into a new group with an existing group that has a common prefix.

However, when a parameter is present grouping must only be done AFTER that route, this case is accounted for. In all other cases, where there's no collision routes can be grouped freely because if a group was matched other groups wouldn't have matched.

After all the groups are created the groups are optimised. Groups with fewer than 3 children are inlined into the parent group. This is because a group with 2 children would potentially result in 3 prefix checks while if they are inlines it's 2 checks.

Like with the previous optimisation I've profiled this using blackfire. But the match function didn't show up anymore. I've added `usleep` calls in the dumped matcher during profiling, which made it show up again. I've verified with @simensen that this is because the wall time of the function was too small for it to be of any interest. When it DID get detected, because of more tasks running, it would show up with around 250 nanoseconds. In comparison, the previous speed improvement brought the wall time down from 7ms to ~2.5ms on a set of ~800 routes.

Because of the altered grouping behaviour I've not modified the PrefixCollection but I've created a new StaticPrefixCollection and updated the PhpMatcherDumper to use that instead.

Commits
-------

449b6912dc [Routing] Optimised dumped matcher
2017-03-22 12:45:31 -07:00
Frank de Jonge
449b6912dc [Routing] Optimised dumped matcher 2017-03-22 12:45:25 -07:00
Fabien Potencier
f99dfb0204 feature #21708 [DI] Add and wire ServiceSubscriberInterface - aka explicit service locators (nicolas-grekas)
This PR was squashed before being merged into the 3.3-dev branch (closes #21708).

Discussion
----------

[DI] Add and wire ServiceSubscriberInterface - aka explicit service locators

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

This PR implements the second and missing part of #20658: it enables objects to declare their service dependencies in a similar way than we do for EventSubscribers: via a static method. Here is the interface and its current description:
```php
namespace Symfony\Component\DependencyInjection;

/**
 * A ServiceSubscriber exposes its dependencies via the static {@link getSubscribedServices} method.
 *
 * The getSubscribedServices method returns an array of service types required by such instances,
 * optionally keyed by the service names used internally. Service types that start with an interrogation
 * mark "?" are optional, while the other ones are mandatory service dependencies.
 *
 * The injected service locators SHOULD NOT allow access to any other services not specified by the method.
 *
 * It is expected that ServiceSubscriber instances consume PSR-11-based service locators internally.
 * This interface does not dictate any injection method for these service locators, although constructor
 * injection is recommended.
 *
 * @author Nicolas Grekas <p@tchwork.com>
 */
interface ServiceSubscriberInterface
{
    /**
     * Returns an array of service types required by such instances, optionally keyed by the service names used internally.
     *
     * For mandatory dependencies:
     *
     *  * array('logger' => 'Psr\Log\LoggerInterface') means the objects use the "logger" name
     *    internally to fetch a service which must implement Psr\Log\LoggerInterface.
     *  * array('Psr\Log\LoggerInterface') is a shortcut for
     *  * array('Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface')
     *
     * otherwise:
     *
     *  * array('logger' => '?Psr\Log\LoggerInterface') denotes an optional dependency
     *  * array('?Psr\Log\LoggerInterface') is a shortcut for
     *  * array('Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface')
     *
     * @return array The required service types, optionally keyed by service names
     */
    public static function getSubscribedServices();
}
```

We could then have eg a controller-as-a-service implement this interface, and be auto or manually wired according to the return value of this method - using the "kernel.service_subscriber" tag to do so.
eg:

```yaml
services:
  App\Controller\FooController:
    arguments: [service_container]
    tags:
      - name: kernel.service_subscriber
        key: logger
        service: monolog.logger.foo_channel
```

The benefits are:
- it keeps the lazy-behavior gained by service locators / container injection
- it allows the referenced services to be made private from the pov of the main Symfony DIC - thus enables some compiler optimizations
- it makes dependencies autowirable (while keeping manual wiring possible)
- it does not add any strong coupling at the architecture level
- and most importantly and contrary to regular container injection, *it makes dependencies explicit* - each classes declaring which services it consumes.

Some might argue that:
- it requires to be explicit - thus more verbose. Yet many others think it's a good thing - ie it's worth it.
- some coupling happens at the dependency level, since you need to get the DI component to get the interface definition. This is something that the PHP-FIG could address at some point.

Commits
-------

c5e80a2b09 implement ServiceSubscriberInterface where applicable
9b7df39865 [DI] Add and wire ServiceSubscriberInterface
2017-03-22 12:35:53 -07:00
Nicolas Grekas
c5e80a2b09 implement ServiceSubscriberInterface where applicable 2017-03-22 20:26:10 +01:00
Nicolas Grekas
9b7df39865 [DI] Add and wire ServiceSubscriberInterface 2017-03-22 20:26:09 +01:00
Fabien Potencier
fa36ce8858 minor #22067 [Yaml] ParseException: pcre.backtrack_limit reached (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Yaml] ParseException: pcre.backtrack_limit reached

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

while merging 3.2 into master, I noticed that `testCanParseVeryLongValue` is triggering this error on master, due to this regexp that we added for handling yaml tags. This regexp needs to be fixed so that we can merge the test case.

ping @GuilhemN

Commits
-------

f0256f1aa5 [Yaml] Fix pcre.backtrack_limit reached
2017-03-22 12:08:11 -07:00
Fabien Potencier
065bf489fa feature #22011 [FrameworkBundle][Serializer] Add option to register a circular_reference_handler (lyrixx)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle][Serializer] Add option to register a circular_reference_handler

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

---

Right now, it's quite hard (especially for new comers) to register a CircularReferenceHandler:

![screenshot1](https://cloud.githubusercontent.com/assets/408368/23959193/ce19bcec-09a4-11e7-82c7-80abd7b7f602.png)

---

This PR introduce an option to wire a service to the internal Object Normalizer.

Commits
-------

0a638f5352 [FrameworkBundle][Serializer] Add option to register a "circular_reference_handler"
2017-03-22 12:06:37 -07:00
Fabien Potencier
ad95227f73 bug #21208 [Validator] Add object handling of invalid constraints in Composite (SenseException)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #21208).

Discussion
----------

[Validator] Add object handling of invalid constraints in Composite

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

This PR fixes a minor bug described in #21206. The constraint `Symfony\Component\Validator\Constraints\Composite` doesn't check in it's exception handling if the wrongly created instance of a nested constraint is an object, which is the expected type for a constraint.

Commits
-------

4bd2c22871 [Validator] Add object handling of invalid constraints in Composite
2017-03-22 12:05:14 -07:00
Claudio Zizza
4bd2c22871 [Validator] Add object handling of invalid constraints in Composite 2017-03-22 12:05:13 -07:00
Fabien Potencier
7b6006488e feature #19673 [DI] Deprecate Container::isFrozen and introduce isCompiled (ro0NL)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Deprecate Container::isFrozen and introduce isCompiled

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | yes |
| Tests pass? | yes |
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any |
| License | MIT |
| Doc PR | reference to the documentation PR, if any |

This deprecates the concept of freezing a container, implied by `Container::isFrozen`. However, freezing happens due compilation (`Container::compile`). So having just `isCompiled` instead seems more intuitive, and plays along well with `ContainerBuilder`.

Before/After;
- `Container::isFrozen`
  - Checks if the parameter bag is frozen, but is deprecated in 3.2
  - In 4.0 this methods does not exists and can be replaced with `getParameterBag() instanceof FrozenParameterBag` _or_ `isCompiled()`. Depending on what you want (to clarify; the behavior is different when passing a frozen bag to the constructor)
- `Container::isCompiled`
  - Truly checks if `compile()` has ran, and is a new feature
- `ContainerBuilder::merge` etc.
  - Now uses `isCompiled` instead of `isFrozen`, ie. we allow for it till compilation regarding the state of the paramater bag

Commits
-------

6abd312800 [DI] Deprecate Container::isFrozen and introduce isCompiled
2017-03-22 12:01:37 -07:00
Roland Franssen
6abd312800 [DI] Deprecate Container::isFrozen and introduce isCompiled 2017-03-22 19:49:34 +01:00
Fabien Potencier
c97407ee17 feature #19954 [Console] Exclude empty namespaces in text descriptor (ro0NL)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Console] Exclude empty namespaces in text descriptor

| Q | A |
| --- | --- |
| Branch? | "master" |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any |
| License | MIT |
| Doc PR | reference to the documentation PR, if any |

Before:

```
$ bin/console

 doctrine
  doctrine:mapping:convert                [orm:convert:mapping] Convert mapping information between supported formats.
 orm <----
 router
  router:match                            Helps debug routes by simulating a path info match

$ bin/console list orm

  [Symfony\Component\Debug\Exception\ContextErrorException]
  Warning: max(): Array must contain at least one element

$ bin/console list generate

Available commands for the "generate" namespace:
  generate:bundle      Generates a bundle
  generate:command     Generates a console command
  generate:controller  Generates a controller
```

After:

```
$ bin/console

 doctrine
  doctrine:mapping:convert                [orm:convert:mapping] Convert mapping information between supported formats.
 router
  router:match                            Helps debug routes by simulating a path info match

$ bin/console list orm

Available commands for the "orm" namespace:
  orm:convert:mapping  Convert mapping information between supported formats.

$ bin/console list generate

Available commands for the "generate" namespace:
  generate:bundle             Generates a bundle
  generate:command            Generates a console command
  generate:controller         Generates a controller
  generate:doctrine:crud      Generates a CRUD based on a Doctrine entity
  generate:doctrine:entities  Generates entity classes and method stubs from your mapping information
  generate:doctrine:entity    Generates a new Doctrine entity inside a bundle
  generate:doctrine:form      Generates a form type class based on a Doctrine entity
```

Overrules #19776 but also includes other fixes related to aliases that popped up when writing tests 👍

Commits
-------

d5a7608036 [Console] Exclude empty namespaces in text descriptor
2017-03-22 11:48:53 -07:00
Fabien Potencier
858af7158f feature #21093 [Lock] Create a lock component (jderusse)
This PR was squashed before being merged into the 3.3-dev branch (closes #21093).

Discussion
----------

[Lock] Create a lock component

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | they will
| Fixed tickets | #20382
| License       | MIT
| Doc PR        | symfony/symfony-docs#7364

This PR aim to add a new component Lock going further than the FileSystem\LockHandler by allowing remote backend (like Redis, memcache, etc)
Inspired by

## Usage

The simplest way to use lock is to inject an instance of a Lock in your service
```php
class MyService
{
    private $lock;

    public function __construct(LockInterface $lock)
    {
        $this->lock = $lock;
    }

    public function run()
    {
        $this->lock->acquire(true);

        // If I'm here, no exception had been raised. Lock is acquired
        try {
            // do my job
        } finally {
            $this->lock->release();
        }
    }
}
```
Configured with something like
```yaml
services:
    app.my_service:
        class: AppBundle\MyService
        arguments:
            - app.lock.my_service
    app.lock.my_service:
        class: Symfony\Component\Lock\Lock
        factory: ['@locker', createLock]
        arguments: ['my_service']
```

If you need to lock serveral resource on runtime, wou'll nneed to inject the LockFactory.
```php
class MyService
{
    private $lockFactory;

    public function __construct(LockFactoryInterface $lockFactory)
    {
        $this->lockFactory = $lockFactory;
    }

    public function run()
    {
        foreach ($this->items as $item) {
            $lock = $this->lockFactory->createLock((string) $item);

            try {
                $lock->acquire();
            } catch (LockConflictedException $e) {
                continue;
            }

            // When I'm here, no exception had been, raised. Lock is acquired
            try {
                // do my job
            } finally {
                $lock->release();
            }
        }
    }
}
```
Configured with something like
```yaml
services:
    app.my_service:
        class: AppBundle\MyService
        arguments:
            - '@locker'
```

This component allow you to refresh an expirable lock.
This is usefull, if you run a long operation split in several small parts.
If you lock with a ttl for the overall operatoin time and your process crash, the lock will block everybody for the defined TTL.
But thank to the refresh method, you're able to lock for a small TTL, and refresh it between each parts.
```php
class MyService
{
    private $lock;

    public function __construct(LockInterface $lock)
    {
        $this->lock = $lock;
    }

    public function run()
    {
        $this->lock->acquire(true);

        try {
            do {
                $finished = $this->performLongTask();

                // Increase the expire date by 300 more seconds
                $this->lock->refresh();
            } while (!$finished)
            // do my job
        } finally {
            $this->lock->release();
        }
    }
}
```

## Naming anc implementation choise

```
$lock->acquire()
vs
$lock->lock()
```

Choose to use acquire, because this component is full of `lock` Symfony\Component\Lock\Lock::Lock` raised a E_TOO_MANY_LOCK in my head.

```
$lock->acquire(false);
$lock->acquire(true);
vs
$lock->aquire()
$lock->waitAndAquire()
```

Not a big fan of flag feature and 2. But I choose to use the blocking flag to offer a simple (and common usecase) implementation

```
$lock = $factory->createLock($key);
$lock->acquire();
vs
$lock->aquire($key)
```

I choose to a the pool of locks implementation. It allow the user to create 2 instances and use cross lock even in the same process.

```
interface LockInterface
final class Lock implements LockInterface
vs
final class Lock
```

I choose to use a Interface even if there is only one implementaiton to offer an extension point here

# TODO

## In this PR
* [x] tests
* [x] add logs
* [x] offer several redis connectors
* [x] try other store implementation to validate the architecture/interface

## In other PR
* documentation
* add configuration in framework bundle
* add stop watch in the debug bar
* improve the combined store (takes the drift into account and elapsed time between each store)
* implement other stores (memcache, ...)
* use this component in session manipulation (fixes #4976)

Commits
-------

018e0fc330 [Lock] Create a lock component
2017-03-22 11:45:21 -07:00
Jérémy Derussé
018e0fc330 [Lock] Create a lock component 2017-03-22 11:45:19 -07:00
Roland Franssen
d5a7608036 [Console] Exclude empty namespaces in text descriptor 2017-03-22 19:41:00 +01:00
Fabien Potencier
6327b4161d feature #21007 [WebProfilerBundle] Improve AJAX toolbar panel (ro0NL)
This PR was squashed before being merged into the 3.3-dev branch (closes #21007).

Discussion
----------

[WebProfilerBundle] Improve AJAX toolbar panel

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

Before

![image](https://cloud.githubusercontent.com/assets/1047696/21394974/072b3570-c79b-11e6-8104-23e9be365b0b.png)

![image](https://cloud.githubusercontent.com/assets/1047696/21383263/1dc484fc-c765-11e6-84e8-7133d67da324.png)

After

![image](https://cloud.githubusercontent.com/assets/1047696/21394997/1a508cb8-c79b-11e6-87de-962ac41c9022.png)

![image](https://cloud.githubusercontent.com/assets/1047696/21383308/53b4f196-c765-11e6-8993-2645f342c7e9.png)

Commits
-------

afbcaa7a32 [WebProfilerBundle] Improve AJAX toolbar panel
2017-03-22 11:29:13 -07:00
Roland Franssen
afbcaa7a32 [WebProfilerBundle] Improve AJAX toolbar panel 2017-03-22 11:28:54 -07:00
Fabien Potencier
d378947321 feature #20642 [FrameworkBundle] Add project directory default for installing assets (Noah Heck)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Add project directory default for installing assets

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

This allows the `assets:install` console command to have a fallback default of the project root directory.

Current behavior is to install assets only in the `target` of the current working directory.

Commits
-------

7a11f3ecf3 [FrameworkBundle] Add project directory default for installing assets
2017-03-22 11:06:20 -07:00
Fabien Potencier
1cb9afde12 feature #20365 [TwigBridge] Handle form label attributes like others (ro0NL)
This PR was squashed before being merged into the 3.3-dev branch (closes #20365).

Discussion
----------

[TwigBridge] Handle form label attributes like others

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

The HTML for rendering attributes is duplicated in multiple blocks, making it error prone/hard to maintain.

Next, the label attributes followed a different approach. Imo. all should follow the same base rendering, showing the above is actually an issue.

Commits
-------

e317e0aeab [TwigBridge] Handle form label attributes like others
2017-03-22 10:41:18 -07:00
Roland Franssen
e317e0aeab [TwigBridge] Handle form label attributes like others 2017-03-22 10:41:14 -07:00
Fabien Potencier
a4a41662a6 feature #22010 [FrameworkBundle][Translator] Make the Translator works with any PSR-11 container (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle][Translator] Make the Translator works with any PSR-11 container

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

Uses a service-locator for collected translation loaders and replace the single call of `getParameter()` by an optional constructor argument.

Commits
-------

85177a649e [FrameworkBundle] Make Translator works with any PSR-11 container
2017-03-22 09:31:28 -07:00
Robin Chalas
85177a649e [FrameworkBundle] Make Translator works with any PSR-11 container 2017-03-22 16:47:35 +01:00