diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php index 201e92cbdd..ce8618181b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php @@ -12,9 +12,19 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormView; +use Symfony\Component\Form\FormInterface; class TextareaType extends AbstractType { + /** + * {@inheritdoc} + */ + public function buildView(FormView $view, FormInterface $form) + { + $view->set('pattern', null); + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index 6aa326711c..5b6305e387 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -220,6 +220,10 @@ class FormFactory implements FormFactoryInterface while (null !== $type) { if ($type instanceof FormTypeInterface) { + if ($type->getName() == $type->getParent($options)) { + 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))); + } + $this->addType($type); } else { $type = $this->getType($type); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 9071292bf3..7cbce2de59 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -523,7 +523,8 @@ class Request if ($this->server->has('HTTP_CLIENT_IP')) { return $this->server->get('HTTP_CLIENT_IP'); } elseif (self::$trustProxy && $this->server->has('HTTP_X_FORWARDED_FOR')) { - return $this->server->get('HTTP_X_FORWARDED_FOR'); + $clientIp = explode(',', $this->server->get('HTTP_X_FORWARDED_FOR'), 2); + return isset($clientIp[0]) ? trim($clientIp[0]) : ''; } } @@ -948,6 +949,24 @@ class Request $this->format = $format; } + public function setLocale($locale) + { + if (!$this->hasSession()) { + throw new \LogicException('Forward compatibility for Request::setLocale() requires the session to be set.'); + } + + $this->session->setLocale($locale); + } + + public function getLocale() + { + if (!$this->hasSession()) { + throw new \LogicException('Forward compatibility for Request::getLocale() requires the session to be set.'); + } + + return $this->session->getLocale(); + } + /** * Gets the format associated with the request. * diff --git a/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php b/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php index 714fdfb543..85326a6ee0 100644 --- a/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php +++ b/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php @@ -1491,11 +1491,13 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase { $form = $this->factory->createNamed('textarea', 'na&me', 'foo&bar', array( 'property_path' => 'name', + 'pattern' => 'foo', )); $this->assertWidgetMatchesXpath($form->createView(), array(), '/textarea [@name="na&me"] + [not(@pattern)] [.="foo&bar"] ' ); diff --git a/tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php b/tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php index 4e1ab4a02a..cde875a4c2 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php @@ -544,6 +544,8 @@ class RequestTest extends \PHPUnit_Framework_TestCase array('88.88.88.88', true, '127.0.0.1', null, '88.88.88.88'), array('::1', false, '::1', null, null), array('2620:0:1cfe:face:b00c::3', true, '::1', '2620:0:1cfe:face:b00c::3', null), + array('2620:0:1cfe:face:b00c::3', true, '::1', null, '2620:0:1cfe:face:b00c::3, ::1'), + array('88.88.88.88', true, '123.45.67.89', null, '88.88.88.88, 87.65.43.21, 127.0.0.1'), ); }