Commit Graph

29950 Commits

Author SHA1 Message Date
Nicolas Grekas
6bfa483712 Merge branch '3.2'
* 3.2:
  [DI] Remove unused legacy arg in XmlFileLoaderTest
2017-03-05 10:42:14 +01:00
Nicolas Grekas
d0ac91a815 minor #21874 [DI] Remove unused legacy arg in XmlFileLoaderTest (nicolas-grekas)
This PR was merged into the 3.2 branch.

Discussion
----------

[DI] Remove unused legacy arg in XmlFileLoaderTest

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

Commits
-------

db4ab9d [DI] Remove unused legacy arg in XmlFileLoaderTest
2017-03-05 10:41:56 +01:00
Nicolas Grekas
db4ab9d0d6 [DI] Remove unused legacy arg in XmlFileLoaderTest 2017-03-05 01:06:55 +01:00
Nicolas Grekas
8953d0bc85 minor #21867 [Form] fix BC layer for form type guessers (xabbuh)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Form] fix BC layer for form type guessers

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

Commits
-------

5c38c4f [Form] fix BC layer for form type guessers
2017-03-04 17:06:00 +01:00
Christian Flothmann
5c38c4f2e5 [Form] fix BC layer for form type guessers 2017-03-04 16:52:39 +01:00
Fabien Potencier
5abb41608b minor #21866 [FrameworkBundle] fix upgrade file (xabbuh)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] fix upgrade file

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

Commits
-------

903ee47957 fix upgrade file
2017-03-04 07:39:44 -08:00
Christian Flothmann
903ee47957 fix upgrade file 2017-03-04 16:15:59 +01:00
Fabien Potencier
b118c650a3 feature #21815 [FrameworkBundle][HttpKernel] Move ControllerArgumentValueResolverPass to the HttpKernel component (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle][HttpKernel] Move ControllerArgumentValueResolverPass to the HttpKernel 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
-------

8bad8a109c Move ControllerArgumentValueResolverPass to the HttpKernel component
2017-03-04 07:06:49 -08:00
Fabien Potencier
255b645d1b feature #21824 Add deprecation note on routing class parameters (lepiaf)
This PR was merged into the 3.3-dev branch.

Discussion
----------

Add deprecation note on routing class parameters

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

Create PR with note about deprecation of class parameters.

https://github.com/symfony/symfony/pull/21739#issuecomment-283413593

Commits
-------

5b0641ebe1 Add deprecation note on routing class parameters
2017-03-04 07:01:34 -08:00
Nicolas Grekas
ecd1ba3ef1 minor #21863 [Security] fix test class location (xabbuh)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Security] fix test class location

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

Keeping the test file in the old location means that it is not available in the `symfony/security-http` subtree split.

Commits
-------

b4e803a [Security] fix test class location
2017-03-04 13:27:15 +01:00
Nicolas Grekas
a358675972 Merge branch '3.2'
* 3.2:
  [Security] fix Composer constraint
  Provide less state in getRequestFormat
  fix test class location
  Static code analysis with Php Inspections (EA Extended): dead code dropped, couple bugs fixed
  Adding use statement for InvalidArgumentException
2017-03-04 13:23:47 +01:00
Nicolas Grekas
4ee9d563c5 Merge branch '2.8' into 3.2
* 2.8:
  [Security] fix Composer constraint
  Provide less state in getRequestFormat
  fix test class location
  Static code analysis with Php Inspections (EA Extended): dead code dropped, couple bugs fixed
2017-03-04 13:23:14 +01:00
Nicolas Grekas
6e9d1bbf32 Merge branch '2.7' into 2.8
* 2.7:
  [Security] fix Composer constraint
  Provide less state in getRequestFormat
  fix test class location
  Static code analysis with Php Inspections (EA Extended): dead code dropped, couple bugs fixed
2017-03-04 13:20:59 +01:00
Nicolas Grekas
d75ca7fa44 minor #21864 [Security] fix Composer constraint (xabbuh)
This PR was merged into the 2.7 branch.

Discussion
----------

[Security] fix Composer constraint

| 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 `MAX_USERNAME_LENGTH` constant introduced by #18733 that is used in the `UsernamePasswordFormAuthenticationListener` was first part of Symfony 2.7.13 and 2.8.6.

Commits
-------

69a572d [Security] fix Composer constraint
2017-03-04 13:01:21 +01:00
Christian Flothmann
69a572dc5d [Security] fix Composer constraint 2017-03-04 12:40:30 +01:00
Nicolas Grekas
af40fd789c minor #21862 [Security] fix test class location (xabbuh)
This PR was merged into the 2.7 branch.

Discussion
----------

[Security] fix test class location

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

Keeping the test file in the old location means that it is not available in the `symfony/security-http` subtree split.

Commits
-------

1ed0092 fix test class location
2017-03-04 11:57:10 +01:00
Nicolas Grekas
d45008d2d1 bug #21805 Provide less state in getRequestFormat (dawehner)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #21805).

Discussion
----------

Provide less state in getRequestFormat

Let's assume you multiple lines of code calling to ```Request::getRequestFormat```providing different default values.

```
$request->getRequestFormat();
$request->getRequestFormat('json')
```

As of HEAD this causes the second call to return 'html', unless its set explicit via ```setRequestFormat()```.

IMHO this is state which can be avoided.

Note: This also helps Drupal.

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

Commits
-------

1d43007 Provide less state in getRequestFormat
2017-03-04 11:53:39 +01:00
Daniel Wehner
1d43007f3c Provide less state in getRequestFormat 2017-03-04 11:53:31 +01:00
Christian Flothmann
b4e803a1ce [Security] fix test class location 2017-03-04 11:27:29 +01:00
Christian Flothmann
1ed0092a62 fix test class location 2017-03-04 11:20:42 +01:00
Nicolas Grekas
5898ec2c5e minor #21855 SCA with Php Inspections (EA Extended) (kalessil)
This PR was merged into the 2.7 branch.

Discussion
----------

SCA with Php Inspections (EA Extended)

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

Commits
-------

e1773ee Static code analysis with Php Inspections (EA Extended): dead code dropped, couple bugs fixed
2017-03-04 10:49:48 +01:00
Nicolas Grekas
31b0ea3f44 bug #21860 [Form] fix BC layer of Form DependencyInjection extension (xabbuh)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Form] fix BC layer of Form DependencyInjection extension

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

Commits
-------

ab487e4 fix BC layer of Form DependencyInjection extension
2017-03-04 10:40:37 +01:00
Christian Flothmann
ab487e48ca fix BC layer of Form DependencyInjection extension 2017-03-04 00:22:30 +01:00
Vladimir Reznichenko
e1773ee2b8 Static code analysis with Php Inspections (EA Extended): dead code dropped, couple bugs fixed 2017-03-03 17:35:37 +01:00
Fabien Potencier
2da12fc080 bug #21851 Adding use statement for InvalidArgumentException (Nyholm)
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #21851).

Discussion
----------

Adding use statement for InvalidArgumentException

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

This is a super minor bugfix. We should tell what InvalidArgumentException we throw. I consider this a bugfix and not a BC break because `Symfony\Component\Translation\Exception\InvalidArgumentException` has always been the intention.

Commits
-------

187f65bb33 Adding use statement for InvalidArgumentException
2017-03-03 07:24:16 -08:00
Tobias Nyholm
187f65bb33 Adding use statement for InvalidArgumentException 2017-03-03 07:24:16 -08:00
Fabien Potencier
f9d0d3d35a feature #21854 [Router] Follow symlinks and skip dots in the annotation directory loader (jakzal)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Router] Follow symlinks and skip dots in the annotation directory loader

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

Following #21833, this change will make the `AnnotationDirectoryLoader` consistent with other loaders.

<!--
- Bug fixes must be submitted against the lowest 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 the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

Commits
-------

344114024b [Router] Follow symlinks and skip dots in the annotation directory loader
2017-03-03 07:20:25 -08:00
Jakub Zalas
344114024b
[Router] Follow symlinks and skip dots in the annotation directory loader
This will make it consistent with other loaders.
2017-03-03 16:02:38 +01:00
Robin Chalas
8bad8a109c Move ControllerArgumentValueResolverPass to the HttpKernel component 2017-03-03 13:55:06 +01:00
Nicolas Grekas
119087a446 minor #21845 [Routing] Fix AnnotationDirectionLoaderTest (chalasr)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Routing] Fix AnnotationDirectionLoaderTest

| Q             | A
| ------------- | ---
| Branch?       | master
| Tests pass? | yes

This directory contains more annotated classes on master, one being read twice (perhaps a bug?)

Commits
-------

6f84877 [Routing] Fix AnnotationDirectionLoaderTest
2017-03-03 11:43:04 +01:00
Robin Chalas
6f84877138 [Routing] Fix AnnotationDirectionLoaderTest 2017-03-03 10:58:26 +01:00
Nicolas Grekas
44842786bd minor #21843 [FrameworkBundle] fix a minor typo (xabbuh)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] fix a minor typo

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

Commits
-------

fdfcb22 [FrameworkBundle] fix a minor typo
2017-03-03 10:08:21 +01:00
Christian Flothmann
fdfcb220e5 [FrameworkBundle] fix a minor typo 2017-03-03 09:31:18 +01:00
Fabien Potencier
1a957100c2 Merge branch '3.2'
* 3.2:
  [Config] removed obsolete code
  [Form] Improve rounding precision
  [Routing] Ignore hidden directories when loading routes from annotations
  fixed CS
2017-03-02 13:35:04 -08:00
Fabien Potencier
86675f3faa Merge branch '2.8' into 3.2
* 2.8:
  fixed CS
2017-03-02 13:34:34 -08:00
Fabien Potencier
a19e3fe970 Merge branch '2.7' into 2.8
* 2.7:
  fixed CS
2017-03-02 13:33:27 -08:00
Fabien Potencier
cb12e323a5 minor #21814 fixed CS (fabpot)
This PR was merged into the 2.7 branch.

Discussion
----------

fixed CS

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| 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
-------

ad0bb6ac53 fixed CS
2017-03-02 13:32:57 -08:00
Fabien Potencier
50b9126f13 feature #18193 [FrameworkBundle] Introduce autowirable ControllerTrait (dunglas)
This PR was squashed before being merged into the 3.3-dev branch (closes #18193).

Discussion
----------

[FrameworkBundle] Introduce autowirable ControllerTrait

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

This is the missing part of the new controller system and it's fully BC with the old one.

Used together with the existing autowiring system, #17608 and [DunglasActionBundle](https://github.com/dunglas/DunglasActionBundle) it permits to inject explicit dependencies in controllers with 0 line of config. It's a great DX improvement for Symfony.
It also has a lot of another advantages including enabling to reuse controller accros frameworks and make them easier to test. See https://dunglas.fr/2016/01/dunglasactionbundle-symfony-controllers-redesigned/ for all arguments.

Magic methods of old controllers are still available if you use this new trait in actions.

For instance, the [`BlogController::newAction`](https://github.com/symfony/symfony-demo/blob/master/src/AppBundle/Controller/Admin/BlogController.php#L70) form the `symfony-demo` can now looks like:

``` php
namespace AppBundle\Action\Admin;

use AppBundle\Form\PostType;
use AppBundle\Utils\Slugger;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class NewAction {
    use ControllerTrait;

    private $slugger;

    public function __construct(Slugger $slugger)
    {
        $this->slugger = $slugger;
    }

    /**
     * @Route("/new", name="admin_post_new")
     */
    public function __invoke(Request $request)
    {
        $post = new Post();
        $post->setAuthorEmail($this->getUser()->getEmail());

        $form = $this->createForm(PostType::class, $post)->add('saveAndCreateNew', SubmitType::class);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $post->setSlug($this->slugger->slugify($post->getTitle()));
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->persist($post);
            $entityManager->flush();

            $this->addFlash('success', 'post.created_successfully');
            if ($form->get('saveAndCreateNew')->isClicked()) {
                return $this->redirectToRoute('admin_post_new');
            }

            return $this->redirectToRoute('admin_post_index');
        }

        return $this->render('admin/blog/new.html.twig', array(
            'post' => $post,
            'form' => $form->createView(),
        ));
    }
}
```

As you can see, there is no need to register the `slugger` service in `services.yml` anymore and the dependency is explicitly injected. In fact the container is not injected in controllers anymore.

Convenience methods still work if the `ControllerTrait` is used (of course it's not mandatory). Here I've made the choice to use an invokable class but this is 100% optional, a class can still contain several actions if wanted.

Annotations like `@Route` still work too. The old `abstract` controller isn't deprecated. There is no valid reason to deprecate it IMO. People liking using the "old" way still can.

Unless in #16863, there is only one trait. This trait/class is basically a bunch of proxy methods to help newcomers. If you want to use only some methods, or want explicit dependencies (better), just inject the service you need in the constructor and don't use the trait.

I'll create open a PR on the standard edition soon to include ActionBundle and provide a dev version of the standard edition to be able to play with this new system.

I'll also backport tests added to the old controller test in 2.3+.

**Edit:** It now uses getter injection to benefit from lazy service loading by default.

Commits
-------

1f2521e347 [FrameworkBundle] Introduce autowirable ControllerTrait
2017-03-02 12:20:21 -08:00
Kévin Dunglas
1f2521e347 [FrameworkBundle] Introduce autowirable ControllerTrait 2017-03-02 12:20:19 -08:00
Fabien Potencier
9e66aaf7a6 minor #21840 [Config] Fix associative sorting in FileLoader (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Config] Fix associative sorting in FileLoader

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

To make master green again :)

Commits
-------

97a69d9e6b [Config] Fix associative sorting in FileLoader
2017-03-02 12:13:33 -08:00
Nicolas Grekas
97a69d9e6b [Config] Fix associative sorting in FileLoader 2017-03-02 20:13:25 +01:00
Fabien Potencier
26c54c700b simplified code 2017-03-02 10:25:18 -08:00
Fabien Potencier
3b4a8f3730 feature #20680 DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. (FractalizeR)
This PR was squashed before being merged into the 3.3-dev branch (closes #20680).

Discussion
----------

DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented.

This PR teaches \Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::sanitizeParam support objects, which implement __toString and therefore can be represented as a string with more sense, than "(object) ClassName". It also includes test for the feature.

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | [20673](https://github.com/symfony/symfony/issues/20673)
| License       | MIT
| Doc PR        | no

Commits
-------

f2970f22ac DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented.
2017-03-02 10:22:47 -08:00
Vladislav Rastrusny
f2970f22ac DoctrineDataCollector: taught sanitizeParam to support classes with __toString implemented. 2017-03-02 10:22:46 -08:00
Fabien Potencier
e2e9c94721 bug #21833 [Config] Sort "globbed" paths to make them predictable (nicolas-grekas)
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Config] Sort "globbed" paths to make them predictable

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

Spotted while reviewing #21832
ping @jakzal FYI

Note that glob already sorts its output, and Finder and glob skip dot dirs.

Commits
-------

ea1defff53 [Config] Sort "globbed" paths to make them predictable
2017-03-02 08:00:18 -08:00
Fabien Potencier
6aa87febf0 [Config] removed obsolete code 2017-03-02 07:58:09 -08:00
Fabien Potencier
e1558cc042 Merge branch '2.8' into 3.2
* 2.8:
  [Form] Improve rounding precision
  [Routing] Ignore hidden directories when loading routes from annotations
2017-03-02 07:57:24 -08:00
Fabien Potencier
db38c6f629 Merge branch '2.7' into 2.8
* 2.7:
  [Form] Improve rounding precision
  [Routing] Ignore hidden directories when loading routes from annotations
2017-03-02 07:56:34 -08:00
Fabien Potencier
c579b96cef bug #21832 [Routing] Ignore hidden directories when loading routes from annotations (jakzal)
This PR was merged into the 2.7 branch.

Discussion
----------

[Routing] Ignore hidden directories when loading routes from annotations

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

The problem surfaced after implementing #18869. Therefore it doesn't exist on 2.7, but I'd still merge it there to avoid conflicts when merging between branches. Without this fix, the oldest branch the added test will fail is 3.2.

Commits
-------

ce9df0237c [Routing] Ignore hidden directories when loading routes from annotations
2017-03-02 07:54:09 -08:00
Fabien Potencier
058121819c bug #21769 [Form] Improve rounding precision (foaly-nr1)
This PR was squashed before being merged into the 2.7 branch (closes #21769).

Discussion
----------

[Form] Improve rounding precision

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

For full details see https://github.com/symfony/symfony/issues/21734 from https://github.com/symfony/symfony/issues/21734#issuecomment-282552802 onwards.

Excerpt:

```php
$number = floor(37.37*100); // double(3736)
var_dump($number);
$number = floor(bcmul(37.37, 100)); // double(3737)
var_dump($number);
```

From http://php.net/manual/en/language.types.float.php#language.types.float:

> Additionally, rational numbers that are exactly representable as floating point numbers in base 10, like 0.1 or 0.7, do not have an exact representation as floating point numbers in base 2, which is used internally, no matter the size of the mantissa. Hence, they cannot be converted into their internal binary counterparts without a small loss of precision. This can lead to confusing results: for example, floor((0.1+0.7)*10) will usually return 7 instead of the expected 8, since the internal representation will be something like 7.9999999999999991118....
>
> So never trust floating number results to the last digit, and do not compare floating point numbers directly for equality. If higher precision is necessary, the arbitrary precision math functions and gmp functions are available.

Commits
-------

e50804cef4 [Form] Improve rounding precision
2017-03-02 07:52:24 -08:00