Skip to content

Commit 07de761

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: (30 commits) Update validators.ro.xlf add non-standard port to HTTP_HOST fixed attribute "source-language" for translations Update PluralizationRules.php Update validators.pt_BR.xlf Translated remaining items (57-72) Updated Vietnamese translation 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 [Component/Security] Fixed some phpdocs in Security/Core Completed Luxembourgish translation Fixing the Logger deprecation notices to match the correct method name it should be informing of ... Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_simple.html.php src/Symfony/Component/Console/Application.php
2 parents 8c47a9f + 2381680 commit 07de761

File tree

52 files changed

+1072
-105
lines changed

Some content is hidden

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

52 files changed

+1072
-105
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/composer.json

Lines changed: 1 addition & 1 deletion
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",

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/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
@@ -297,12 +297,18 @@ public function request($method, $uri, array $parameters = array(), array $files
297297
}
298298

299299
$uri = $this->getAbsoluteUri($uri);
300-
301300
$server = array_merge($this->server, $server);
301+
302302
if (!$this->history->isEmpty()) {
303303
$server['HTTP_REFERER'] = $this->history->current()->getUri();
304304
}
305+
305306
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
307+
308+
if ($port = parse_url($uri, PHP_URL_PORT)) {
309+
$server['HTTP_HOST'] .= ':'.$port;
310+
}
311+
306312
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
307313

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

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ public function testRequestHttpHeaders()
160160
$client->request('GET', 'https://www.example.com');
161161
$headers = $client->getRequest()->getServer();
162162
$this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
163+
164+
$client = new TestClient();
165+
$client->request('GET', 'http://www.example.com:8080');
166+
$headers = $client->getRequest()->getServer();
167+
$this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port');
163168
}
164169

165170
public function testRequestURIConversion()
@@ -416,6 +421,24 @@ public function testFollowRedirectWithHeaders()
416421
$this->assertEquals($headers, $client->getRequest()->getServer());
417422
}
418423

424+
public function testFollowRedirectWithPort()
425+
{
426+
$headers = array(
427+
'HTTP_HOST' => 'www.example.com:8080',
428+
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
429+
'HTTPS' => false
430+
);
431+
432+
$client = new TestClient();
433+
$client->followRedirects(false);
434+
$client->setNextResponse(new Response('', 302, array(
435+
'Location' => 'http://www.example.com:8080/redirected',
436+
)));
437+
$client->request('GET', 'http://www.example.com:8080/');
438+
439+
$this->assertEquals($headers, $client->getRequest()->getServer());
440+
}
441+
419442
public function testBack()
420443
{
421444
$client = new TestClient();

src/Symfony/Component/Console/Application.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ public function renderException($e, $output)
695695
do {
696696
$title = sprintf(' [%s] ', get_class($e));
697697
$len = $strlen($title);
698-
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
698+
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
699+
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : (defined('HHVM_VERSION') ? 1 << 31 : PHP_INT_MAX);
699700
$formatter = $output->getFormatter();
700701
$lines = array();
701702
foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) {
@@ -1052,7 +1053,7 @@ public function extractNamespace($name, $limit = null)
10521053
* if nothing is found in $collection, try in $abbrevs
10531054
*
10541055
* @param string $name The string
1055-
* @param array|Traversable $collection The collection
1056+
* @param array|\Traversable $collection The collection
10561057
*
10571058
* @return array A sorted array of similar string
10581059
*/

src/Symfony/Component/CssSelector/Parser/Parser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $s
378378
$stream->skipWhitespace();
379379
$value = $stream->getNext();
380380

381+
if ($value->isNumber()) {
382+
// if the value is a number, it's casted into a string
383+
$value = new Token(Token::TYPE_STRING, (string) $value->getValue(), $value->getPosition());
384+
}
385+
381386
if (!($value->isIdentifier() || $value->isString())) {
382387
throw SyntaxErrorException::unexpectedToken('string or identifier', $value);
383388
}

src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function getParserTestData()
133133
array('div#foobar', array('Hash[Element[div]#foobar]')),
134134
array('div:not(div.foo)', array('Negation[Element[div]:not(Class[Element[div].foo])]')),
135135
array('td ~ th', array('CombinedSelector[Element[td] ~ Element[th]]')),
136+
array('.foo[data-bar][data-baz=0]', array("Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]")),
136137
);
137138
}
138139

src/Symfony/Component/HttpKernel/Tests/Logger.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function emerg($message, array $context = array())
101101
*/
102102
public function crit($message, array $context = array())
103103
{
104-
trigger_error('Use crit() which is PSR-3 compatible', E_USER_DEPRECATED);
104+
trigger_error('Use critical() which is PSR-3 compatible', E_USER_DEPRECATED);
105105

106106
$this->log('critical', $message, $context);
107107
}
@@ -111,7 +111,7 @@ public function crit($message, array $context = array())
111111
*/
112112
public function err($message, array $context = array())
113113
{
114-
trigger_error('Use err() which is PSR-3 compatible', E_USER_DEPRECATED);
114+
trigger_error('Use error() which is PSR-3 compatible', E_USER_DEPRECATED);
115115

116116
$this->log('error', $message, $context);
117117
}
@@ -121,7 +121,7 @@ public function err($message, array $context = array())
121121
*/
122122
public function warn($message, array $context = array())
123123
{
124-
trigger_error('Use warn() which is PSR-3 compatible', E_USER_DEPRECATED);
124+
trigger_error('Use warning() which is PSR-3 compatible', E_USER_DEPRECATED);
125125

126126
$this->log('warning', $message, $context);
127127
}

src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public function format(\DateTime $dateTime)
100100
/**
101101
* Return the formatted ICU value for the matched date characters
102102
*
103-
* @param string $dateChars The date characters to be replaced with a formatted ICU value
104-
* @param DateTime $dateTime A DateTime object to be used to generate the formatted value
103+
* @param string $dateChars The date characters to be replaced with a formatted ICU value
104+
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
105105
*
106106
* @return string The formatted value
107107
*

0 commit comments

Comments
 (0)