Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9ba2cd

Browse files
Merge branch '2.8' into 3.0
* 2.8: Fix merge [Form] fix BC break introduced with prototype_data option [Ldap] Escape carriage returns in LDAP DNs. Upgrade for 2.8: ContainerAware was deprecated in favour of ContainerAwareTrait [ci skip] Fix wrong method name mapping in UPGRADE-3.0.md Use correct height for clearer [Validator] fixed raising violations to a maximum of one Conflicts: UPGRADE-2.8.md
2 parents 1ccdf66 + f176156 commit f9ba2cd

File tree

8 files changed

+83
-12
lines changed

8 files changed

+83
-12
lines changed

UPGRADE-3.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ UPGRADE FROM 2.x to 3.0
1111
| `registerNamespaces()` | `addPrefixes()`
1212
| `registerPrefixes()` | `addPrefixes()`
1313
| `registerNamespaces()` | `addPrefix()`
14-
| `registerPrefixes()` | `addPrefix()`
14+
| `registerPrefix()` | `addPrefix()`
1515
| `getNamespaces()` | `getPrefixes()`
1616
| `getNamespaceFallbacks()` | `getFallbackDirs()`
1717
| `getPrefixFallbacks()` | `getFallbackDirs()`

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public function testSubmitSingleNonExpandedStringCastableIdentifier()
603603

604604
$this->persist(array($entity1, $entity2));
605605

606-
$field = $this->factory->createNamed('name', 'entity', null, array(
606+
$field = $this->factory->createNamed('name', EntityType::class, null, array(
607607
'multiple' => false,
608608
'expanded' => false,
609609
'em' => 'default',
@@ -625,7 +625,7 @@ public function testSubmitSingleStringCastableIdentifierExpanded()
625625

626626
$this->persist(array($entity1, $entity2));
627627

628-
$field = $this->factory->createNamed('name', 'entity', null, array(
628+
$field = $this->factory->createNamed('name', EntityType::class, null, array(
629629
'multiple' => false,
630630
'expanded' => true,
631631
'em' => 'default',
@@ -651,7 +651,7 @@ public function testSubmitMultipleNonExpandedStringCastableIdentifierForExisting
651651

652652
$this->persist(array($entity1, $entity2, $entity3));
653653

654-
$field = $this->factory->createNamed('name', 'entity', null, array(
654+
$field = $this->factory->createNamed('name', EntityType::class, null, array(
655655
'multiple' => true,
656656
'expanded' => false,
657657
'em' => 'default',
@@ -682,7 +682,7 @@ public function testSubmitMultipleNonExpandedStringCastableIdentifier()
682682

683683
$this->persist(array($entity1, $entity2, $entity3));
684684

685-
$field = $this->factory->createNamed('name', 'entity', null, array(
685+
$field = $this->factory->createNamed('name', EntityType::class, null, array(
686686
'multiple' => true,
687687
'expanded' => false,
688688
'em' => 'default',
@@ -707,7 +707,7 @@ public function testSubmitMultipleStringCastableIdentifierExpanded()
707707

708708
$this->persist(array($entity1, $entity2, $entity3));
709709

710-
$field = $this->factory->createNamed('name', 'entity', null, array(
710+
$field = $this->factory->createNamed('name', EntityType::class, null, array(
711711
'multiple' => true,
712712
'expanded' => true,
713713
'em' => 'default',

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<style>
2222
{{ include('@WebProfiler/Profiler/toolbar.css.twig', { 'position': position, 'floatable': true }) }}
2323
</style>
24-
<div id="sfToolbarClearer-{{ token }}" style="clear: both; height: 38px;"></div>
24+
<div id="sfToolbarClearer-{{ token }}" style="clear: both; height: 36px;"></div>
2525
{% endif %}
2626

2727
<div id="sfToolbarMainContent-{{ token }}" class="sf-toolbarreset clear-fix" data-no-turbolink>

src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ class CollectionType extends AbstractType
2727
public function buildForm(FormBuilderInterface $builder, array $options)
2828
{
2929
if ($options['allow_add'] && $options['prototype']) {
30-
$prototype = $builder->create($options['prototype_name'], $options['entry_type'], array_replace(array(
30+
$prototypeOptions = array_replace(array(
3131
'label' => $options['prototype_name'].'label__',
32-
), $options['entry_options'], array(
33-
'data' => $options['prototype_data'],
34-
)));
32+
), $options['options']);
33+
34+
if (null !== $options['prototype_data']) {
35+
$prototypeOptions['data'] = $options['prototype_data'];
36+
}
37+
38+
$prototype = $builder->create($options['prototype_name'], $options['entry_type'], $prototypeOptions);
3539
$builder->setAttribute('prototype', $prototype->getForm());
3640
}
3741

src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,20 @@ public function testPrototypeData()
288288

289289
$this->assertSame('foo', $form->createView()->vars['prototype']->vars['value']);
290290
}
291+
292+
/**
293+
* @group legacy
294+
*/
295+
public function testLegacyPrototypeData()
296+
{
297+
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), array(
298+
'allow_add' => true,
299+
'prototype' => true,
300+
'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
301+
'options' => array(
302+
'data' => 'bar',
303+
),
304+
));
305+
$this->assertSame('bar', $form->createView()->vars['prototype']->vars['value']);
306+
}
291307
}

src/Symfony/Component/Ldap/LdapClient.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,20 @@ public function find($dn, $query, $filter = '*')
9999
*/
100100
public function escape($subject, $ignore = '', $flags = 0)
101101
{
102-
return ldap_escape($subject, $ignore, $flags);
102+
$value = ldap_escape($subject, $ignore, $flags);
103+
104+
// Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns.
105+
if ((int) $flags & LDAP_ESCAPE_DN) {
106+
if (!empty($value) && $value[0] === ' ') {
107+
$value = '\\20'.substr($value, 1);
108+
}
109+
if (!empty($value) && $value[strlen($value) - 1] === ' ') {
110+
$value = substr($value, 0, -1).'\\20';
111+
}
112+
$value = str_replace("\r", '\0d', $value);
113+
}
114+
115+
return $value;
103116
}
104117

105118
private function connect()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Component\Ldap\Tests;
13+
14+
use Symfony\Component\Ldap\LdapClient;
15+
use Symfony\Polyfill\Php56\Php56 as p;
16+
17+
/**
18+
* @requires extension ldap
19+
*/
20+
class LdapClientTest extends \PHPUnit_Framework_TestCase
21+
{
22+
public function testLdapEscape()
23+
{
24+
$ldap = new LdapClient();
25+
26+
$this->assertEquals('\20foo\3dbar\0d(baz)*\20', $ldap->escape(" foo=bar\r(baz)* ", null, p::LDAP_ESCAPE_DN));
27+
}
28+
}

src/Symfony/Component/Validator/Constraints/BicValidator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function validate($value, Constraint $constraint)
3838
->setParameter('{{ value }}', $this->formatValue($value))
3939
->setCode(Bic::INVALID_LENGTH_ERROR)
4040
->addViolation();
41+
42+
return;
4143
}
4244

4345
// must contain alphanumeric values only
@@ -46,6 +48,8 @@ public function validate($value, Constraint $constraint)
4648
->setParameter('{{ value }}', $this->formatValue($value))
4749
->setCode(Bic::INVALID_CHARACTERS_ERROR)
4850
->addViolation();
51+
52+
return;
4953
}
5054

5155
// first 4 letters must be alphabetic (bank code)
@@ -54,6 +58,8 @@ public function validate($value, Constraint $constraint)
5458
->setParameter('{{ value }}', $this->formatValue($value))
5559
->setCode(Bic::INVALID_BANK_CODE_ERROR)
5660
->addViolation();
61+
62+
return;
5763
}
5864

5965
// next 2 letters must be alphabetic (country code)
@@ -62,6 +68,8 @@ public function validate($value, Constraint $constraint)
6268
->setParameter('{{ value }}', $this->formatValue($value))
6369
->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)
6470
->addViolation();
71+
72+
return;
6573
}
6674

6775
// should contain uppercase characters only
@@ -70,6 +78,8 @@ public function validate($value, Constraint $constraint)
7078
->setParameter('{{ value }}', $this->formatValue($value))
7179
->setCode(Bic::INVALID_CASE_ERROR)
7280
->addViolation();
81+
82+
return;
7383
}
7484
}
7585
}

0 commit comments

Comments
 (0)