8000 Merge branch '2.8' into 3.0 · ocical/symfony@4a08c88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a08c88

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: Updated all the README files [TwigBundle] Fix failing test on appveyor Improved the error message when using "@" in a decorated service Improve error reporting in router panel of web profiler [DoctrineBridge][Form] Fix performance regression in EntityType [FrameworkBundle] Fix a regression in handling absolute and namespaced template paths Allow to normalize \Traversable minor [Form] fix tests added by symfony#16886 Remove _path from query parameters when fragment is a subrequest and request attributes are already set Added tests for _path removal in FragmentListener Simplified everything Added a test Fixed the problem in an easier way Fixed a syntax issue Improved the error message when a template is not found [CodingStandards] Conformed to coding standards [TwigBundle] fixed Include file locations in "Template could not be found" exception
2 parents 897d813 + 0f3e1a3 commit 4a08c88

File tree

48 files changed

+421
-983
lines changed
  • Security
  • Serializer
  • Stopwatch
  • Templating
  • Translation
  • Validator
  • Yaml
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    48 files changed

    +421
    -983
    lines changed

    src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -146,7 +146,9 @@ public function loadChoicesForValues(array $values, $value = null)
    146146

    147147
    // Optimize performance in case we have an object loader and
    148148
    // a single-field identifier
    149-
    if (null === $value && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
    149+
    $optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
    150+
    151+
    if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
    150152
    $unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
    151153
    $objectsById = array();
    152154
    $objects = array();

    src/Symfony/Bridge/Doctrine/README.md

    Lines changed: 4 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,8 +7,7 @@ various Symfony components.
    77
    Resources
    88
    ---------
    99

    10-
    You can run the unit tests with the following command:
    11-
    12-
    $ cd path/to/Symfony/Bridge/Doctrine/
    13-
    $ composer install
    14-
    $ phpunit
    10+
    * [Contributing](https://symfony.com/doc/current/contributing/index.html)
    11+
    * [Report issues](https://github.com/symfony/symfony/issues) and
    12+
    [send Pull Requests](https://github.com/symfony/symfony/pulls)
    13+
    in the [main Symfony repository](https://github.com/symfony/symfony)

    src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

    Lines changed: 24 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -802,6 +802,30 @@ public function testOverrideChoicesValuesWithCallable()
    802802
    $this->assertSame('BooGroup/Bar', $field->getViewData());
    803803
    }
    804804

    805+
    public function testChoicesForValuesOptimization()
    806+
    {
    807+
    $entity1 = new SingleIntIdEntity(1, 'Foo');
    808+
    $entity2 = new SingleIntIdEntity(2, 'Bar');
    809+
    810+
    $this->persist(array($entity1, $entity2));
    811+
    812+
    $field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
    813+
    'em' => 'default',
    814+
    'class' => self::SINGLE_IDENT_CLASS 1241 ,
    815+
    'choice_label' => 'name',
    816+
    ));
    817+
    818+
    $this->em->clear();
    819+
    820+
    $field->submit(1);
    821+
    822+
    $unitOfWorkIdentityMap = $this->em->getUnitOfWork()->getIdentityMap();
    823+
    $managedEntitiesNames = array_map('strval', $unitOfWorkIdentityMap['Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity']);
    824+
    825+
    $this->assertContains((string) $entity1, $managedEntitiesNames);
    826+
    $this->assertNotContains((string) $entity2, $managedEntitiesNames);
    827+
    }
    828+
    805829
    public function testGroupByChoices()
    806830
    {
    807831
    $item1 = new GroupableEntity(1, 'Foo', 'Group1');

    src/Symfony/Bridge/Monolog/README.md

    Lines changed: 4 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,8 +6,7 @@ Provides integration for Monolog with various Symfony components.
    66
    Resources
    77
    ---------
    88

    9-
    You can run the unit tests with the following command:
    10-
    11-
    $ cd path/to/Symfony/Bridge/Monolog/
    12-
    $ composer install
    13-
    $ phpunit
    9+
    * [Contributing](https://symfony.com/doc/current/contributing/index.html)
    10+
    * [Report issues](https://github.com/symfony/symfony/issues) and
    11+
    [send Pull Requests](https://github.com/symfony/symfony/pulls)
    12+
    in the [main Symfony repository](https://github.com/symfony/symfony)

    src/Symfony/Bridge/Propel1/README.md

    Lines changed: 12 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,12 @@
    1+
    Propel Bridge
    2+
    =============
    3+
    4+
    Provides integration for Propel with various Symfony components.
    5+
    6+
    Resources
    7+
    ---------
    8+
    9+
    * [Contributing](https://symfony.com/doc/current/contributing/index.html)
    10+
    * [Report issues](https://github.com/symfony/symfony/issues) and
    11+
    [send Pull Requests](https://github.com/symfony/symfony/pulls)
    12+
    in the [main Symfony repository](https://github.com/symfony/symfony)

    src/Symfony/Bridge/ProxyManager/README.md

    Lines changed: 4 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,10 +6,9 @@ Provides integration for [ProxyManager][1] with various Symfony components.
    66
    Resources
    77
    ---------
    88

    9-
    You can run the unit tests with the following command:
    10-
    11-
    $ cd path/to/Symfony/Bridge/ProxyManager/
    12-
    $ composer install
    13-
    $ phpunit
    9+
    * [Contributing](https://symfony.com/doc/current/contributing/index.html)
    10+
    * [Report issues](https://github.com/symfony/symfony/issues) and
    11+
    [send Pull Requests](https://github.com/symfony/symfony/pulls)
    12+
    in the [main Symfony repository](https://github.com/symfony/symfony)
    1413

    1514
    [1]: https://github.com/Ocramius/ProxyManager

    src/Symfony/Bridge/Twig/README.md

    Lines changed: 4 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,9 +7,7 @@ Symfony components.
    77
    Resources
    88
    ---------
    99

    10-
    If you want to run the unit tests, install dev dependencies before
    11-
    running PHPUnit:
    12-
    13-
    $ cd path/to/Symfony/Bridge/Twig/
    14-
    $ composer install
    15-
    $ phpunit
    10+
    * [Contributing](https://symfony.com/doc/current/contributing/index.html)
    11+
    * [Report issues](https://github.com/symfony/symfony/issues) and
    12+
    [send Pull Requests](https://github.com/symfony/symfony/pulls)
    13+
    in the [main Symfony repository](https://github.com/symfony/symfony)

    src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php

    Lines changed: 6 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -55,7 +55,7 @@ public function parse($name)
    5555
    throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
    5656
    }
    5757

    58-
    if (!preg_match('/^(?:([^:]*):)?(?:([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) {
    58+
    if (!preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches) || $this->isAbsolutePath($name) || 0 === strpos($name, '@')) {
    5959
    return parent::parse($name);
    6060
    }
    6161

    @@ -71,4 +71,9 @@ public function parse($name)
    7171

    7272
    return $this->cache[$name] = $template;
    7373
    }
    74+
    75+
    private function isAbsolutePath($file)
    76+
    {
    77+
    return (bool) preg_match('#^(?:/|[a-zA-Z]:)#', $file);
    78+
    }
    7479
    }

    src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

    Lines changed: 6 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -66,6 +66,12 @@ public function parseProvider()
    6666
    array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
    6767
    array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
    6868
    array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
    69+
    array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')),
    70+
    array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')),
    71+
    array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')),
    72+
    array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')),
    73+
    array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')),
    74+
    array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')),
    6975
    array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
    7076
    array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')),
    7177
    array('name', 'name', 'name', new BaseTemplateReference('name')),

    src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

    Lines changed: 2 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -76,19 +76,18 @@ protected function findTemplate($template, $throw = true)
    7676
    try {
    7777
    $file = parent::findTemplate($logicalName);
    7878
    } catch (\Twig_Error_Loader $e) {
    79-
    $previous = $e;
    79+
    $twigLoaderException = $e;
    8080

    8181
    // for BC
    8282
    try {
    8383
    $template = $this->parser->parse($template);
    8484
    $file = $this->locator->locate($template);
    8585
    } catch (\Exception $e) {
    86-
    $previous = $e;
    8786
    }
    8887
    }
    8988

    9089
    if (false === $file || null === $file) {
    91-
    throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $logicalName), -1, null, $previous);
    90+
    throw $twigLoaderException;
    9291
    }
    9392

    9493
    return $this->cache[$logicalName] = $file;

    0 commit comments

    Comments
     (0)
    0