Commit Graph

30542 Commits

Author SHA1 Message Date
Fabien Potencier
ac01aadbd6 bug #21810 #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile (Antanas Arvasevicius)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #21810).

Discussion
----------

#21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile

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

then security.yml  providers was with upper case, on container compile error was thrown:
````
[04:39:32][Ant output]      [exec]      [exec] > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
[04:39:32][Ant output]      [exec]      [exec]
[04:39:32][Ant output]      [exec]      [exec]
[04:39:32][Ant output]      [exec]      [exec]   [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
[04:39:32][Ant output]      [exec]      [exec]   The service "security.authentication.provider.simple_form.default" has a de
[04:39:32][Ant output]      [exec]      [exec]   pendency on a non-existent service "security.user.provider.concrete.carrier
[04:39:32][Ant output]      [exec]      [exec]   User".

`````

Problem has occurred with this commit line:
fbd9f88e31 (diff-2be909961a57bf75fbb600c1f5fc46e3R320)

Issue fixes with this PR.

Commits
-------

6d23c8c41c #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile
2017-03-23 08:57:18 -07:00
Antanas Arvasevicius
6d23c8c41c #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile 2017-03-23 08:57:18 -07:00
Fabien Potencier
db8d87dce2 feature #21819 [Twig Bridge] A simpler way to retrieve flash messages (javiereguiluz)
This PR was squashed before being merged into the 3.3-dev branch (closes #21819).

Discussion
----------

[Twig Bridge] A simpler way to retrieve flash messages

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

Getting flash messages in templates is more complex than it could be. Main problems:

1. It's too low level: you need to get the "flash bag" (and first, learn what a "flash bag" is) and then you need to call the internal method: `all()`, `get()`, etc.
2. You need to be careful because the session will start automatically when you ask for flashes (even if there are no flashes). You can prevent this with the `{% if app.session is not null and app.session.started %}` code, but it's boring to always use that.

So, I propose to add a new `app.flashes` helper that works as follows.

---

## Get all the flash messages

### Before

```twig
{% if app.session is not null and app.session.started %}
    {% for label, messages in app.session.flashbag.all %}
        {% for message in messages %}
            <div class="alert alert-{{ label }}">
                {{ message }}
            </div>
        {% endfor %}
    {% endfor %}
{% endif %}
```

### After

```twig
{% for label, messages in app.flashes %}
    {% for message in messages %}
        <div class="alert alert-{{ label }}">
            {{ message }}
        </div>
    {% endfor %}
{% endfor %}
```

---

## Get only the flashes of type `notice`

```twig
{% if app.session is not null and app.session.started %}
    {% for message in app.session.flashbag.get('notice') %}
        <div class="alert alert-notice">
            {{ message }}
        </div>
    {% endfor %}
{% endif %}
```

### After

```twig
{% for message in app.flashes('notice') %}
    <div class="alert alert-notice">
        {{ message }}
    </div>
{% endfor %}
```

---

As an added bonus, you can get any number of flash messages because the method allows to pass an array of flash types:

```twig
{% for label, messages in app.flashes(['warning', 'error']) %}
    {% for message in messages %}
        <div class="alert alert-{{ label }}">
            {{ message }}
        </div>
    {% endfor %}
{% endfor %}
```

Commits
-------

5a56b23327 [Twig Bridge] A simpler way to retrieve flash messages
2017-03-23 08:48:12 -07:00
Javier Eguiluz
5a56b23327 [Twig Bridge] A simpler way to retrieve flash messages 2017-03-23 08:48:05 -07:00
Nicolas Grekas
3de0d9b33f minor #22122 Fix tests (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Fix tests

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

Commits
-------

ea84aa1 Fix tests
2017-03-23 13:32:01 +01:00
Javier Eguiluz
f354a47450 bug #22123 [WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page (e-moe)
This PR was merged into the 2.8 branch.

Discussion
----------

[WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page

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

Commits
-------

d980e70 [WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page
2017-03-23 12:38:07 +01:00
Nikolay Labinskiy
d980e706ad [WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page 2017-03-23 11:48:03 +02:00
Robin Chalas
ea84aa1868 Fix tests 2017-03-23 10:34:23 +01:00
Fabien Potencier
bafa8e29e0 feature #19026 [Security] Strengthen comparison of target_url vs login_path (mrzard)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Security] Strengthen comparison of target_url vs login_path

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

Commits
-------

ac9d75a09e [Security] Strengthen comparison of target_url vs login_path
2017-03-22 16:29:02 -07:00
Fabien Potencier
6f998375ff updated CHANGELOG 2017-03-22 16:26:17 -07:00
Fabien Potencier
ce067a3844 feature #19496 [DX][Form][Validator] Add ability check if cocrete constraint fails. (Koc)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[DX][Form][Validator] Add ability check if cocrete constraint fails.

| Q | A |
| --- | --- |
| Branch? | master |
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | wait for travis |
| Fixed tickets | #15154 |
| License | MIT |
| Doc PR | should open |

Sometimes for big forms with multiple constraints we should handle some errors separately.

``` php
// when using validator
$constraintViolations = $validator->validate(...);
if (count($constraintViolations->findByCodes(UniqueEntity::NOT_UNIQUE_ERROR))) {
  // display some message or send email or etc
}

// when using forms
if (count($form->getErrors()->findByCodes(UniqueEntity::NOT_UNIQUE_ERROR))) {
  // display some message or send email or etc
}
```

This PR add some useful methods to handle this. Before we should iterate all failed constraints using foreach.

Feel free to suggest better names for new methods.

Commits
-------

29a3a7e0d6 Add ability retrieve errors by their code.
2017-03-22 16:25:22 -07:00
Fabien Potencier
b59660c23d minor #22119 [Lock] Adjust lock delay to avoid false error tests (jderusse)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Lock] Adjust lock delay to avoid false error tests

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

Adjust the clockDelay to fix tests
This test is here to:

T0.
* Fork A, B, C

T1.
* A acquire Lock then start sleeping for 3*clockDelay
* B start sleeping for 1*clockDelay
* C start sleeping for 1*clockDelay

T2
* B wakeup AND try to acquire lock in wait mode
* C wakeup AND try to acquire lock in non wait mode (lock should be till acquired by A)

T4
* A release Lock
* B acquire lock and release it

At the end, this tests assert than:
* A acquire and delete the lock
* B acquire and delete the lock
* C failed to acquire the lock

The point is, this test is time sensitive, and if the fork is too slow, A, B and C are not synchronized and C is able to acquire Lock.

This PR adjuste clock delay to reduce false failures

Commits
-------

33f2a9a6f7 Adjust lock delay to avoid false error tests
2017-03-22 16:13:19 -07:00
Fabien Potencier
ba4d6bce29 feature #18140 [Console] Add console.ERROR event and deprecate console.EXCEPTION (wouterj)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Console] Add console.ERROR event and deprecate console.EXCEPTION

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

The current `console.EXCEPTION` event is only dispatched for exceptions during the execution of `Command#execute()`. All other exceptions (e.g. the ones thrown by listeners to events) are catched by the `try ... catch` loop in `Application#doRunCommand()`. This means that there is _no way to override exception handling_.
## The Solution

This PR adds a `console.ERROR` event which has the same scope as the default `try ... catch` loop. This allows to customize all exception handling.

In order to keep BC, a new event was created and `console.EXCEPTION` was deprecated.

Commits
-------

c02a4c9857 Added a console.ERROR event
2017-03-22 16:10:45 -07:00
Fabien Potencier
42e5b4e10d feature #22120 [FrameworkBundle] Multiple services on one Command class (SenseException)
This PR was squashed before being merged into the 3.3-dev branch (closes #22120).

Discussion
----------

[FrameworkBundle] Multiple services on one Command class

rebased version of #19305

Commits
-------

2b82fcb437 [FrameworkBundle] Multiple services on one Command class
2017-03-22 16:05:06 -07:00
Claudio Zizza
2b82fcb437 [FrameworkBundle] Multiple services on one Command class 2017-03-22 16:05:04 -07:00
Fabien Potencier
ce9cd71372 fixed Yoda condition 2017-03-22 16:03:14 -07:00
Fabien Potencier
426a666def minor #22043 Refactor stale-while-revalidate code in HttpCache, add a (first?) test for it (mpdude)
This PR was squashed before being merged into the 3.3-dev branch (closes #22043).

Discussion
----------

Refactor stale-while-revalidate code in HttpCache, add a (first?) test for it

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

I came up with this while trying to hunt a production bug related to handling of stale cache entries under the condition of a busy backend (also see #22033).

It's just a refactoring to make the code more readable plus a new test.

Commits
-------

b14057c88a Refactor stale-while-revalidate code in HttpCache, add a (first?) test for it
2017-03-22 16:02:33 -07:00
Matthias Pigulla
b14057c88a Refactor stale-while-revalidate code in HttpCache, add a (first?) test for it 2017-03-22 16:02:29 -07:00
Jérémy Derussé
33f2a9a6f7
Adjust lock delay to avoid false error tests 2017-03-22 23:42:28 +01:00
Fabien Potencier
05933f3749 minor #22033 Minor cleanups in HttpCache, especially centralize Date header fixup (mpdude)
This PR was submitted for the 2.8 branch but it was merged into the 3.3-dev branch instead (closes #22033).

Discussion
----------

Minor cleanups in HttpCache, especially centralize Date header fixup

| 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        |

I am trying to hunt some issues where the HTTP cache does not revalidate responses (or does not use a cached response?) in the edge case of having `s-maxage = 0` and possibly a backend that's slow to respond.

I don't see yet what exactly my problem is there, but it must somehow be related with the `Date` header handling and/or age calculations in the `HTTPCache`.

As a first step, I'd like to suggest this cleanup in `HTTPCache`. Especially, it would be helpful if we could make sure that there is just one place where we set the `Date` header if the backend does not send one (?). This makes sure we always have this header to base later age calculations on it.

Commits
-------

30639c6af6 Minor cleanups in HttpCache, especially centralize Date header fixup
2017-03-22 15:30:57 -07:00
Matthias Pigulla
30639c6af6 Minor cleanups in HttpCache, especially centralize Date header fixup 2017-03-22 15:30:57 -07:00
Fabien Potencier
0a5998d996 feature #21771 [FrameworkBundle] Add new "controller.service_arguments" tag to inject services into actions (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Add new "controller.service_arguments" tag to inject services into actions

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

Talking with @simensen and @weaverryan, we wondered if we could leverage the `ArgumentResolver` mechanism to make it inject services on demand, using e.g. autowiring.

```php
class PostController
{
  public function indexAction(Request $request, PostRepository $postRepository)
  {
    // PostRepository comes from the container
    $postRepository->findAll(); // ...
  }
}
```

This PR achieves that, using a new "controller.service_arguments" tag. Typically:
```yaml
services:
    AppBundle\Controller\PostController:
        autowire: true
        tags:
            - name: controller.service_arguments
```

It also supports with explicit wiring (thus doesn't necessarily require autowiring if you don't want to use it):
```yaml
services:
    AppBundle\Controller\PostController:
        tags:
            - name: controller.service_arguments
              action: fooAction
              argument: logger
              id: my_logger
```

~~The attached diff is bigger than strictly required for now, until #21770 is merged.~~

Todo:
- [x] rebase on top of #21770 when merged
- [x] add tests
- [x] add cleaning pass to remove empty service locators

Commits
-------

9c6e672780 [FrameworkBundle] Add new "controller.service_arguments" tag to inject services into actions
2017-03-22 15:24:31 -07:00
Fabien Potencier
b2d5ba7db7 feature #22114 [lock] Rename Quorum into Strategy (jderusse)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[lock] Rename Quorum into Strategy

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes (not consistent naming)
| New feature?  | no
| BC breaks?    | yes (but version 3.4 not yet released)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        |

The term `Quorum` in Interface is confusing an not consistent with the Symfony project.
This PR switch to naming `Strategy\StrategyInterface` (like in adapter i `Cache` and `Ldap` component)

Commits
-------

1e9671b993 Rename Quorum into Strategy
2017-03-22 15:21:53 -07:00
Fabien Potencier
2eb5c979fa minor #22117 [Lock] Don't call blindly the redis client (jderusse)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Lock] Don't call blindly the redis client

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

Actual code rely on controls on the constructor. This PR add an assertion to avoid futur bugs

Commits
-------

e4db018b6d Don't call blindly the redis client
2017-03-22 15:17:31 -07:00
Jérémy Derussé
1e9671b993
Rename Quorum into Strategy 2017-03-22 23:05:31 +01:00
Fabien Potencier
f876e58fa6 minor #22116 Fix deprecation message (ogizanagi)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Fix deprecation message

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

My bad, it seems I've never pushed the fix for https://github.com/symfony/symfony/pull/20516#discussion_r103876193 :/

Commits
-------

57427cc01e Fix deprecation message
2017-03-22 15:00:26 -07:00
Maxime Steinhausser
57427cc01e Fix deprecation message 2017-03-22 22:52:11 +01:00
Jérémy Derussé
e4db018b6d
Don't call blindly the redis client 2017-03-22 22:50:35 +01:00
Fabien Potencier
a6b20d1e5c bug #19778 [Security] Fixed roles serialization on token from user object (eko)
This PR was merged into the 2.7 branch.

Discussion
----------

[Security] Fixed roles serialization on token from user object

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

This PR fixes the serialization of tokens when using `Role` objects provided from the user. Indeed, there were actually a reference issue that can causes fatal errors like the following one:

```
FatalErrorException in RoleHierarchy.php line 43:
Error: Call to a member function getRole() on string
```

Here is a small code example to reproduce and its output:

``` php
$user = new Symfony\Component\Security\Core\User\User('name', 'password', [
    new Symfony\Component\Security\Core\Role\Role('name')
]);
$token = new Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, 'password', 'providerKey', $user->getRoles());

$serialized = serialize($token);
$unserialized = unserialize($serialized);

var_dump($unserialized->getRoles());
```

Before:

```
array(1) { [0]=> bool(true) }
```

After:

```
array(1) { [0]=> object(Symfony\Component\Security\Core\Role\Role)#15 (1) {["role":"Symfony\Component\Security\Core\Role\Role":private]=> string(4) "name" } }
```

Thank you

Commits
-------

dfa7f5020e [Security] Fixed roles serialization on token from user object
2017-03-22 14:44:57 -07:00
Nicolas Grekas
4927993835 Merge branch '3.2'
* 3.2:
  Fixed pathinfo calculation for requests starting with a question mark.
  [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
  removed usage of $that
  HttpCache: New test for revalidating responses with an expired TTL
  [Serializer] [XML] Ignore Process Instruction
  [Security] simplify the SwitchUserListenerTest
  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 22:42:42 +01:00
Fabien Potencier
1635a6a4e7 feature #20516 [Security][SecurityBundle] Enhance automatic logout url generation (ogizanagi)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Security][SecurityBundle] Enhance automatic logout url generation

| 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

This should help whenever:

- [the token does not implement the `getProviderKey` method](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php#L89-L99)
- you've got multiple firewalls sharing a same context but a logout listener only define on one of them.

##### Behavior:

> When not providing the firewall key:
>
>- Try to find the key from the token (unless it's an anonymous token)
>- If found, try to get the listener from the key. If the listener is found, stop there.
>- Try from the injected firewall key. If the listener is found, stop there.
>- Try from the injected firewall context. If the listener is found, stop there.
>
>The behavior remains unchanged when providing explicitly the firewall key. No fallback.

Commits
-------

5b7fe852aa [Security][SecurityBundle] Enhance automatic logout url generation
2017-03-22 14:38:03 -07:00
Fabien Potencier
c73009a996 feature #22081 [FrameworkBundle][Validator] Move Validator passes to the component (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle][Validator] Move Validator passes to the component

| 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

Commits
-------

0b741da343 Move AddValidatorInitializersrPass & AddConstraintValidatorsPass to the Validator
2017-03-22 14:26:38 -07:00
Fabien Potencier
a25fd7ddbc minor #22112 Minor PR fixes (ro0NL)
This PR was squashed before being merged into the 3.3-dev branch (closes #22112).

Discussion
----------

Minor PR fixes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes-ish
| 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-->

cc @fabpot  my bad :)

Commits
-------

0728fb91b8 typo
036b0414d6 Minor PR fixes
2017-03-22 14:24:53 -07:00
Fabien Potencier
6a1f5d4dfa feature #20567 [WebProfilerBundle] Improved cookie traffic (ro0NL)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[WebProfilerBundle] Improved cookie traffic

| 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/20455635/a033a814-ae60-11e6-8500-e60146f4619e.png)

Relates to #20569 in terms of getting _all_ the cookies.

Commits
-------

171c6d100e [WebProfilerBundle] Improved cookie traffic
2017-03-22 14:19:48 -07:00
Fabien Potencier
e3d90db747 bug #22036 Set Date header in Response constructor already (mpdude)
This PR was squashed before being merged into the 2.8 branch (closes #22036).

Discussion
----------

Set Date header in Response constructor already

| 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        |

Setting the `Date` header in the `Response` constructor has been removed in #14912 and changed to a more lazy approach in `getDate()`.

That way, methods like `getAge()`, `getTtl()` or `isFresh()` cause side effects as they eventually call `getDate()` and the Request "starts to age" once you call them.

I don't know if this would be a nice test, but current behaviour is

```php
        $response = new Response();
        $response->setSharedMaxAge(10);
        sleep(20);
        $this->assertTrue($response->isFresh());
        sleep(5);
        $this->assertTrue($response->isFresh());
        sleep(5);
        $this->assertFalse($response->isFresh());
```

A particular weird case is the `isCacheable()` method, because it calls `isFresh()` only under certain conditions, like particular status codes, no `ETag` present etc. This symptom is also described under "Cause of the problem" in #19390, however the problem is worked around there in other ways.

So, this PR suggests to effectively revert #14912.

Additionally, I'd like to suggest to move this special handling of the `Date` header into the `ResponseHeaderBag`. If the `ResponseHeaderBag` guards that we always have the `Date`, we would not need special logic in `sendHeaders()` and could also take care of https://github.com/symfony/symfony/pull/14912#issuecomment-110105215.

Commits
-------

3a7fa7ede2 Set Date header in Response constructor already
2017-03-22 14:18:49 -07:00
Matthias Pigulla
3a7fa7ede2 Set Date header in Response constructor already 2017-03-22 14:18:47 -07:00
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