Skip to content

Commit cc188e9

Browse files
committed
Merge branch '3.1'
* 3.1: Fixed BC Layer in DoctrineChoiceLoader [HttpKernel] Add listener that checks when request has both Forwarded and X-Forwarded-For [HttpKernel] Move conflicting origin IPs handling to catch block [travis] Fix deps=low/high patching Fixed some issues of the AccessDecisionManager profiler [DoctrineBridge] fixed default parameter value in UniqueEntityValidator
2 parents 9c74d63 + 080962f commit cc188e9

File tree

15 files changed

+225
-36
lines changed

15 files changed

+225
-36
lines changed

.travis.php renamed to .github/travis.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<?php
22

33
if (4 > $_SERVER['argc']) {
4-
echo "Usage: branch dir1 dir2 ... dirN\n";
4+
echo "Usage: branch version dir1 dir2 ... dirN\n";
55
exit(1);
66
}
77

88
$dirs = $_SERVER['argv'];
99
array_shift($dirs);
1010
$branch = array_shift($dirs);
11+
$version = array_shift($dirs);
1112

1213
$packages = array();
1314
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
1415

1516
foreach ($dirs as $dir) {
16-
if (!`git diff --name-only $branch...HEAD -- $dir`) {
17+
if (!system("git diff --name-only $branch...HEAD -- $dir", $exitStatus)) {
18+
if ($exitStatus) {
19+
exit($exitStatus);
20+
}
1721
continue;
1822
}
1923
echo "$dir\n";
@@ -32,7 +36,7 @@
3236
file_put_contents($dir.'/composer.json', $json);
3337
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
3438

35-
$package->version = 'master' !== $branch ? $branch.'.x-dev' : 'dev-master';
39+
$package->version = 'master' !== $version ? $version.'.x-dev' : 'dev-master';
3640
$package->dist['type'] = 'tar';
3741
$package->dist['url'] = 'file://'.__DIR__."/$dir/package.tar";
3842

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ before_install:
7272
install:
7373
- if [[ ! $skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi
7474
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
75-
- if [[ ! $skip && $deps ]]; then php .travis.php $TRAVIS_BRANCH $COMPONENTS; fi
75+
- if [[ ! $skip && $deps ]]; then git fetch origin $TRAVIS_BRANCH && php .github/travis.php FETCH_HEAD $TRAVIS_BRANCH $COMPONENTS; fi
7676
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
7777
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi
7878
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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\Doctrine\Tests\Fixtures;
13+
14+
use Doctrine\ORM\Mapping as ORM;
15+
16+
/**
17+
* @ORM\Entity
18+
*/
19+
class AssociationEntity2
20+
{
21+
/**
22+
* @var int
23+
* @ORM\Id @ORM\GeneratedValue
24+
* @ORM\Column(type="integer")
25+
*/
26+
private $id;
27+
28+
/**
29+
* @ORM\ManyToOne(targetEntity="SingleIntIdNoToStringEntity")
30+
*
31+
* @var \Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity
32+
*/
33+
public $single;
34+
35+
/**
36+
* @ORM\ManyToOne(targetEntity="CompositeIntIdEntity")
37+
* @ORM\JoinColumns({
38+
* @ORM\JoinColumn(name="composite_id1", referencedColumnName="id1"),
39+
* @ORM\JoinColumn(name="composite_id2", referencedColumnName="id2")
40+
* })
41+
*
42+
* @var \Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity
43+
*/
44+
public $composite;
45+
}

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
2020
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
2121
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
22+
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
23+
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
2224
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
2325
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
2426
use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest;
@@ -127,9 +129,11 @@ private function createSchema(ObjectManager $em)
127129
$schemaTool = new SchemaTool($em);
128130
$schemaTool->createSchema(array(
129131
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'),
132+
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'),
130133
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'),
131134
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'),
132135
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'),
136+
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2'),
133137
));
134138
}
135139

@@ -408,6 +412,42 @@ public function testAssociatedEntity()
408412
->assertRaised();
409413
}
410414

415+
public function testValidateUniquenessNotToStringEntityWithAssociatedEntity()
416+
{
417+
$constraint = new UniqueEntity(array(
418+
'message' => 'myMessage',
419+
'fields' => array('single'),
420+
'em' => self::EM_NAME,
421+
));
422+
423+
$entity1 = new SingleIntIdNoToStringEntity(1, 'foo');
424+
$associated = new AssociationEntity2();
425+
$associated->single = $entity1;
426+
$associated2 = new AssociationEntity2();
427+
$associated2->single = $entity1;
428+
429+
$this->em->persist($entity1);
430+
$this->em->persist($associated);
431+
$this->em->flush();
432+
433+
$this->validator->validate($associated, $constraint);
434+
435+
$this->assertNoViolation();
436+
437+
$this->em->persist($associated2);
438+
$this->em->flush();
439+
440+
$this->validator->validate($associated2, $constraint);
441+
442+
$expectedValue = 'Object of class "Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2" identified by "2"';
443+
444+
$this->buildViolation('myMessage')
445+
->atPath('property.path.single')
446+
->setParameter('{{ value }}', $expectedValue)
447+
->setInvalidValue($expectedValue)
448+
->assertRaised();
449+
}
450+
411451
public function testAssociatedEntityWithNull()
412452
{
413453
$constraint = new UniqueEntity(array(

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ public function validate($entity, Constraint $constraint)
127127
$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
128128
$invalidValue = isset($criteria[$errorPath]) ? $criteria[$errorPath] : $criteria[$fields[0]];
129129

130+
if (is_object($invalidValue) && !method_exists($invalidValue, '__toString')) {
131+
$invalidValue = sprintf('Object of class "%s" identified by "%s"', get_class($entity), implode(', ', $class->getIdentifierValues($entity)));
132+
}
133+
130134
$this->context->buildViolation($constraint->message)
131135
->atPath($errorPath)
132136
->setParameter('{{ value }}', $invalidValue)

src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,9 @@
6161
<argument type="service" id="request_stack" />
6262
<tag name="kernel.event_subscriber" />
6363
</service>
64+
65+
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
66+
<tag name="kernel.event_subscriber" />
67+
</service>
6468
</services>
6569
</container>

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/config": "~2.8|~3.0",
2525
"symfony/event-dispatcher": "~2.8|~3.0",
2626
"symfony/http-foundation": "~3.1",
27-
"symfony/http-kernel": "~3.1",
27+
"symfony/http-kernel": "~3.1.2|~3.2",
2828
"symfony/polyfill-mbstring": "~1.0",
2929
"symfony/filesystem": "~2.8|~3.0",
3030
"symfony/finder": "~2.8|~3.0",

src/Symfony/Bundle/SecurityBundle/Resources/config/collectors.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<argument type="service" id="security.token_storage" on-invalid="ignore" />
1111
<argument type="service" id="security.role_hierarchy" />
1212
<argument type="service" id="security.logout_url_generator" />
13-
<argument type="service" id="debug.security.access.decision_manager" />
13+
<argument type="service" id="security.access.decision_manager" />
1414
</service>
1515
</services>
1616
</container>

src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" ?>
22

33
<container xmlns="http://symfony.com/schema/dic/services"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
88
<service id="debug.security.access.decision_manager" class="Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager" decorates="security.access.decision_manager" public="false">

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.5.9",
20-
"symfony/security": "~3.1",
20+
"symfony/security": "~3.1,>=3.1.2",
2121
"symfony/http-kernel": "~2.8|~3.0",
2222
"symfony/polyfill-php70": "~1.0"
2323
},

0 commit comments

Comments
 (0)