8000 merged 2.0 · DavidChristmann/symfony@a1d1232 · GitHub
[go: up one dir, main page]

Skip to content

Commit a1d1232

Browse files
committed
merged 2.0
2 parents ec30dcb + 286ce0e commit a1d1232

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,19 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15+
use Symfony\Component\Form\FormView;
16+
use Symfony\Component\Form\FormInterface;
1517

1618
class TextareaType extends AbstractType
1719
{
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
public function buildView(FormView $view, FormInterface $form)
24+
{
25+
$view->set('pattern', null);
26+
}
27+
1828
/**
1929
* {@inheritdoc}
2030
*/

src/Symfony/Component/Form/FormFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ public function createNamedBuilder($type, $name, $data = null, array $options =
220220

221221
while (null !== $type) {
222222
if ($type instanceof FormTypeInterface) {
223+
if ($type->getName() == $type->getParent($options)) {
224+
throw new FormException(sprintf('The form type name "%s" for class "%s" cannot be the same as the parent type.', $type->getName(), get_class($type)));
225+
}
226+
223227
$this->addType($type);
224228
} else {
225229
$type = $this->getType($type);

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ public function getClientIp($proxy = false)
523523
if ($this->server->has('HTTP_CLIENT_IP')) {
524524
return $this->server->get('HTTP_CLIENT_IP');
525525
} elseif (self::$trustProxy && $this->server->has('HTTP_X_FORWARDED_FOR')) {
526-
return $this->server->get('HTTP_X_FORWARDED_FOR');
526+
$clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'), 2);
527+
return isset($clientIp[0]) ? trim($clientIp[0]) : '';
527528
}
528529
}
529530

@@ -948,6 +949,24 @@ public function setRequestFormat($format)
948949
$this->format = $format;
949950
}
950951

952+
public function setLocale($locale)
953+
{
954+
if (!$this->hasSession()) {
955+
throw new \LogicException('Forward compatibility for Request::setLocale() requires the session to be set.');
956+
}
957+
958+
$this->session->setLocale($locale);
959+
}
960+
961+
public function getLocale()
962+
{
963+
if (!$this->hasSession()) {
964+
throw new \LogicException('Forward compatibility for Request::getLocale() requires the session to be set.');
965+
}
966+
967+
return $this->session->getLocale();
968+
}
969+
951970
/**
952971
* Gets the format associated with the request.
953972
*

tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,11 +1491,13 @@ public function testTextarea()
14911491
{
14921492
$form = $this->factory->createNamed('textarea', 'na&me', 'foo&bar', array(
14931493
'property_path' => 'name',
1494+
'pattern' => 'foo',
14941495
));
14951496

14961497
$this->assertWidgetMatchesXpath($form->createView(), array(),
14971498
'/textarea
14981499
[@name="na&me"]
1500+
[not(@pattern)]
14991501
[.="foo&bar"]
15001502
'
15011503
);

tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ public function testGetClientIpProvider()
544544
array('88.88.88.88', true, '127.0.0.1', null, '88.88.88.88'),
545545
array('::1', false, '::1', null, null),
546546
array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null),
547+
array('2620:0:1cfe:face:b00c::3', true, '::1', null, '2620:0:1cfe:face:b00c::3, ::1'),
548+
array('88.88.88.88', true, '123.45.67.89', null, '88.88.88.88, 87.65.43.21, 127.0.0.1'),
547549
);
548550
}
549551

0 commit comments

Comments
 (0)
0