8000 Merge branch '2.4' · symfony/symfony@2e2a65c · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e2a65c

Browse files
committed
Merge branch '2.4'
* 2.4: (35 commits) Update validators.ro.xlf add non-standard port to HTTP_HOST fixed attribute "source-language" for translations [Process] clarify idle timeout [Security] fix DI for SimpleFormAuthenticationListener Update PluralizationRules.php Update validators.pt_BR.xlf Translated remaining items (57-72) Updated Vietnamese translation allow null value in fragment handler added missing dot in translation updated Arabic translations Update validators.id.xlf [Validator] Translate validator messages into Brazilian Portuguese Added more Swedish validator translations Update validators.ca.xlf fixed typos in Welsh translation Added missing Croatian translations [Form] fixed allow render 0 and 0.0 numeric input values Fixed validators.nl.xlf ... Conflicts: src/Symfony/Bridge/Twig/composer.json
2 parents 78d49fb + 07de761 commit 2e2a65c

File tree

60 files changed

+1128
-131
lines changed

Some content is hidden

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

60 files changed

+1128
-131
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ services: mongodb
1515

1616
before_script:
1717
- sudo apt-get install parallel
18-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "" >> "~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"; fi;'
19-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
20-
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
21-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
22-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
18+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;'
19+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
20+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
21+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
22+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
2323
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
2424

2525
script:

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,18 @@ public function getEntitiesByIds($identifier, array $values)
8181
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
8282
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);
8383

84+
// Guess type
85+
$entity = current($qb->getRootEntities());
86+
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
87+
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
88+
$parameterType = Connection::PARAM_INT_ARRAY;
89+
} else {
90+
$parameterType = Connection::PARAM_STR_ARRAY;
91+
}
92+
8493
return $qb->andWhere($where)
8594
->getQuery()
86-
->setParameter($parameter, $values, Connection::PARAM_STR_ARRAY)
95+
->setParameter($parameter, $values, $parameterType)
8796
->getResult();
8897
}
8998
}

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
1313

1414
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
15+
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
16+
use Doctrine\DBAL\Connection;
1517

16-
class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
18+
class ORMQueryBuilderLoaderTest extends DoctrineOrmTestCase
1719
{
1820
/**
1921
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
@@ -32,4 +34,43 @@ public function testClosureRequiresTheEntityManager()
3234

3335
new ORMQueryBuilderLoader($closure);
3436
}
37+
38+
public function testIdentifierTypeIsStringArray()
39+
{
40+
$this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity', Connection::PARAM_STR_ARRAY);
41+
}
42+
43+
public function testIdentifierTypeIsIntegerArray()
44+
{
45+
$this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', Connection::PARAM_INT_ARRAY);
46+
}
47+
48+
protected function checkIdentifierType($classname, $expectedType)
49+
{
50+
$em = $this->createTestEntityManager();
51+
52+
$query = $this->getMockBuilder('QueryMock')
53+
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
54+
->getMock();
55+
56+
$query->expects($this->once())
57+
->method('setParameter')
58+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(), $expectedType)
59+
->will($this->returnValue($query));
60+
61+
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
62+
->setConstructorArgs(array($em))
63+
->setMethods(array('getQuery'))
64+
->getMock();
65+
66+
$qb->expects($this->once())
67+
->method('getQuery')
68+
->will($this->returnValue($query));
69+
70+
$qb->select('e')
71+
->from($classname, 'e');
72+
73+
$loader = new ORMQueryBuilderLoader($qb);
74+
$loader->getEntitiesByIds('id', array());
75+
}
3576
}

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,23 @@ public function testAssociatedEntity()
330330
$this->assertEquals(1, $violationsList->count());
331331
}
332332

333+
public function testAssociatedEntityWithNull()
334+
{
335+
$entityManagerName = "foo";
336+
$em = DoctrineTestHelper::createTestEntityManager();
337+
$this->createSchema($em);
338+
$validator = $this->createValidator($entityManagerName, $em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity', array('single'), null, 'findBy', false);
339+
340+
$associated = new AssociationEntity();
341+
$associated->single = null;
342+
343+
$em->persist($associated);
344+
$em->flush();
345+
346+
$violationsList = $validator->validate($associated);
347+
$this->assertEquals(0, $violationsList->count());
348+
}
349+
333350
/**
334351
* @group GH-1635
335352
*/

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function validate($entity, Constraint $constraint)
8989
return;
9090
}
9191

92-
if ($class->hasAssociation($fieldName)) {
92+
if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
9393
/* Ensure the Proxy is initialized before using reflection to
9494
* read its identifiers. This is necessary because the wrapped
9595
* getter methods in the Proxy are being bypassed.

src/Symfony/Bridge/Twig/Extension/ExpressionExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function getFunctions()
3030
);
3131
}
3232

33-
private function createExpression($expression)
33+
public function createExpression($expression)
3434
{
3535
return new Expression($expression);
3636
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Twig\Tests\Extension;
13+
14+
use Symfony\Bridge\Twig\Extension\ExpressionExtension;
15+
use Symfony\Component\ExpressionLanguage\Expression;
16+
17+
class ExpressionExtensionTest extends \PHPUnit_Framework_TestCase
18+
{
19+
protected $helper;
20+
21+
public function testExpressionCreation()
22+
{
23+
$template = "{{ expression('1 == 1') }}";
24+
$twig = new \Twig_Environment(new \Twig_Loader_String(), array('debug' => true, 'cache' => false, 'autoescape' => true, 'optimizations' => 0));
25+
$twig->addExtension(new ExpressionExtension());
26+
27+
$output = $twig->render($template);
28+
$this->assertEquals('1 == 1', $output);
29+
}
30+
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.3.3",
2020
"symfony/security-csrf": "~2.4",
21-
"twig/twig": "~1.11"
21+
"twig/twig": "~1.12"
2222
},
2323
"require-dev": {
2424
"symfony/form": "~2.2",
@@ -29,7 +29,8 @@
2929
"symfony/yaml": "~2.0",
3030
"symfony/security": "~2.4",
3131
"symfony/stopwatch": "~2.2",
32-
"symfony/console": "~2.2"
32+
"symfony/console": "~2.2",
33+
"symfony/expression-language": "~2.4"
3334
},
3435
"suggest": {
3536
"symfony/form": "For using the FormExtension",
@@ -39,7 +40,8 @@
3940
"symfony/translation": "For using the TranslationExtension",
4041
"symfony/yaml": "For using the YamlExtension",
4142
"symfony/security": "For using the SecurityExtension",
42-
"symfony/stopwatch": "For using the StopwatchExtension"
43+
"symfony/stopwatch": "For using the StopwatchExtension",
44+
"symfony/expression": "For using the ExpressionExtension"
4345
},
4446
"autoload": {
4547
"psr-0": { "Symfony\\Bridge\\Twig\\": "" }

src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\RedirectResponse;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
18+
use Symfony\Component\HttpKernel\Exception\HttpException;
1819
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920

2021
/**
@@ -39,11 +40,13 @@ class RedirectController extends ContainerAware
3940
* @param Boolean|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore
4041
*
4142
* @return Response A Response instance
43+
*
44+
* @throws HttpException In case the route name is empty
4245
*/
4346
public function redirectAction(Request $request, $route, $permanent = false, $ignoreAttributes = false)
4447
{
4548
if ('' == $route) {
46-
return new Response(null, $permanent ? 410 : 404);
49+
throw new HttpException($permanent ? 410 : 404);
4750
}
4851

4952
$attributes = array();
@@ -75,11 +78,13 @@ public function redirectAction(Request $request, $route, $permanent = false, $ig
7578
* @param integer|null $httpsPort The HTTPS port (null to keep the current one for the same scheme or the configured port in the container)
7679
*
7780
* @return Response A Response instance
81+
*
82+
* @throws HttpException In case the path is empty
7883
*/
7984
public function urlRedirectAction(Request $request, $path, $permanent = false, $scheme = null, $httpPort = null, $httpsPort = null)
8085
{
8186
if ('' == $path) {
82-
return new Response(null, $permanent ? 410 : 404);
87+
throw new HttpException($permanent ? 410 : 404);
8388
}
8489

8590
$statusCode = $permanent ? 301 : 302;
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
<input type="<?php echo isset($type) ? $view->escape($type) : 'text' ?>" <?php echo $view['form']->block($form, 'widget_attributes') ?><?php if (!empty($value)): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?> />
1+
<input
2+
type="<?php echo isset($type) ? $view->escape($type) : 'text' ?>"
3+
<?php echo $view['form']->block($form, 'widget_attributes') ?>
4+
<?php if (!empty($value) || is_numeric($value)): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?>
5+
/>

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpFoundation\Response;
1515
use Symfony\Component\HttpFoundation\ParameterBag;
1616
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\HttpKernel\Exception\HttpException;
1718
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
1819
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1920

@@ -27,13 +28,19 @@ public function testEmptyRoute()
2728
$request = new Request();
2829
$controller = new RedirectController();
2930

30-
$returnResponse = $controller->redirectAction($request, '', true);
31-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
32-
$this->assertEquals(410, $returnResponse->getStatusCode());
31+
try {
32+
$controller->redirectAction($request, '', true);
33+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
34+
} catch (HttpException $e) {
35+
$this->assertSame(410, $e->getStatusCode());
36+
}
3337

34-
$returnResponse = $controller->redirectAction($request, '', false);
35-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
36-
$this->assertEquals(404, $returnResponse->getStatusCode());
38+
try {
39+
$controller->redirectAction($request, '', false);
40+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
41+
} catch (HttpException $e) {
42+
$this->assertSame(404, $e->getStatusCode());
43+
}
3744
}
3845

3946
/**
@@ -98,13 +105,19 @@ public function testEmptyPath()
98105
$request = new Request();
99106
$controller = new RedirectController();
100107

101-
$returnResponse = $controller->urlRedirectAction($request, '', true);
102-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
103-
$this->assertEquals(410, $returnResponse->getStatusCode());
108+
try {
109+
$controller->urlRedirectAction($request, '', true);
110+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
111+
} catch (HttpException $e) {
112+
$this->assertSame(410, $e->getStatusCode());
113+
}
104114

105-
$returnResponse = $controller->urlRedirectAction($request, '', false);
106-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
107-
$this->assertEquals(404, $returnResponse->getStatusCode());
115+
try {
116+
$controller->urlRedirectAction($request, '', false);
117+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
118+
} catch (HttpException $e) {
119+
$this->assertSame(404, $e->getStatusCode());
120+
}
108121
}
109122

110123
public function testFullURL()

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ protected function createListener($container, $id, $config, $userProvider)
7575
{
7676
$listenerId = parent::createListener($container, $id, $config, $userProvider);
7777

78-
if (isset($config['csrf_provider'])) {
79-
$container
80-
->getDefinition($listenerId)
81-
->addArgument(new Reference($config['csrf_provider']))
82-
;
83-
}
78+
$container
79+
->getDefinition($listenerId)
80+
->addArgument(isset($config['csrf_provider']) ? new Reference($config['csrf_provider']) : null)
81+
;
8482

8583
return $listenerId;
8684
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
6363
protected function createListener($container, $id, $config, $userProvider)
6464
{
6565
$listenerId = parent::createListener($container, $id, $config, $userProvider);
66-
$listener = $container->getDefinition($listenerId);
67-
68-
if (!isset($config['csrf_token_generator'])) {
69-
$listener->addArgument(null);
70-
}
7166

7267
$simpleAuthHandlerId = 'security.authentication.simple_success_failure_handler.'.$id;
7368
$simpleAuthHandler = $container->setDefinition($simpleAuthHandlerId, new DefinitionDecorator('security.authentication.simple_success_failure_handler'));
7469
$simpleAuthHandler->replaceArgument(0, new Reference($config['authenticator']));
7570
$simpleAuthHandler->replaceArgument(1, new Reference($this->getSuccessHandlerId($id)));
7671
$simpleAuthHandler->replaceArgument(2, new Reference($this->getFailureHandlerId($id)));
7772

73+
$listener = $container->getDefinition($listenerId);
7874
$listener->replaceArgument(5, new Reference($simpleAuthHandlerId));
7975
$listener->replaceArgument(6, new Reference($simpleAuthHandlerId));
8076
$listener->addArgument(new Reference($config['authenticator']));

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function toolbarAction(Request $request, $token)
227227

228228
$session = $request->getSession();
229229

230-
if (null !== $session && $session->getFlashBag() instanceof AutoExpireFlashBag) {
230+
if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
231231
// keep current flashes for one more request if using AutoExpireFlashBag
232232
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
233233
}

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function onKernelResponse(FilterResponseEvent $event)
7676

7777
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects) {
7878
$session = $request->getSession();
79-
if ($session && $session->getFlashBag() instanceof AutoExpireFlashBag) {
79+
if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
8080
// keep current flashes for one more request if using AutoExpireFlashBag
8181
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
8282
}

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,18 @@ public function request($method, $uri, array $parameters = array(), array $files
295295
}
296296

297297
$uri = $this->getAbsoluteUri($uri);
298-
299298
$server = array_merge($this->server, $server);
299+
300300
if (!$this->history->isEmpty()) {
301301
$server['HTTP_REFERER'] = $this->history->current()->getUri();
302302
}
303+
303304
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
305+
306+
if ($port = parse_url($uri, PHP_URL_PORT)) {
307+
$server['HTTP_HOST'] .= ':'.$port;
308+
}
309+
304310
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
305311

306312
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);

0 commit comments

Comments
 (0)
0