diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
index d3f9185131..4d23db4ef8 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
@@ -209,7 +209,7 @@ class EntityTypeTest extends TypeTestCase
$field->setData(null);
$this->assertNull($field->getData());
- $this->assertSame('', $field->getClientData());
+ $this->assertSame('', $field->getViewData());
}
public function testSetDataMultipleExpandedNull()
@@ -223,7 +223,7 @@ class EntityTypeTest extends TypeTestCase
$field->setData(null);
$this->assertNull($field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSetDataMultipleNonExpandedNull()
@@ -237,7 +237,7 @@ class EntityTypeTest extends TypeTestCase
$field->setData(null);
$this->assertNull($field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSubmitSingleExpandedNull()
@@ -251,7 +251,7 @@ class EntityTypeTest extends TypeTestCase
$field->bind(null);
$this->assertNull($field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSubmitSingleNonExpandedNull()
@@ -265,7 +265,7 @@ class EntityTypeTest extends TypeTestCase
$field->bind(null);
$this->assertNull($field->getData());
- $this->assertSame('', $field->getClientData());
+ $this->assertSame('', $field->getViewData());
}
public function testSubmitMultipleNull()
@@ -278,7 +278,7 @@ class EntityTypeTest extends TypeTestCase
$field->bind(null);
$this->assertEquals(new ArrayCollection(), $field->getData());
- $this->assertSame(array(), $field->getClientData());
+ $this->assertSame(array(), $field->getViewData());
}
public function testSubmitSingleNonExpandedSingleIdentifier()
@@ -300,7 +300,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
- $this->assertSame('2', $field->getClientData());
+ $this->assertSame('2', $field->getViewData());
}
public function testSubmitSingleNonExpandedCompositeIdentifier()
@@ -323,7 +323,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
- $this->assertSame('1', $field->getClientData());
+ $this->assertSame('1', $field->getViewData());
}
public function testSubmitMultipleNonExpandedSingleIdentifier()
@@ -348,7 +348,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field->isSynchronized());
$this->assertEquals($expected, $field->getData());
- $this->assertSame(array('1', '3'), $field->getClientData());
+ $this->assertSame(array('1', '3'), $field->getViewData());
}
public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
@@ -379,7 +379,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertEquals($expected, $field->getData());
// same object still, useful if it is a PersistentCollection
$this->assertSame($existing, $field->getData());
- $this->assertSame(array('1', '3'), $field->getClientData());
+ $this->assertSame(array('1', '3'), $field->getViewData());
}
public function testSubmitMultipleNonExpandedCompositeIdentifier()
@@ -405,7 +405,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field->isSynchronized());
$this->assertEquals($expected, $field->getData());
- $this->assertSame(array('0', '2'), $field->getClientData());
+ $this->assertSame(array('0', '2'), $field->getViewData());
}
public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
@@ -436,7 +436,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertEquals($expected, $field->getData());
// same object still, useful if it is a PersistentCollection
$this->assertSame($existing, $field->getData());
- $this->assertSame(array('0', '2'), $field->getClientData());
+ $this->assertSame(array('0', '2'), $field->getViewData());
}
public function testSubmitSingleExpanded()
@@ -460,8 +460,8 @@ class EntityTypeTest extends TypeTestCase
$this->assertSame($entity2, $field->getData());
$this->assertFalse($field['1']->getData());
$this->assertTrue($field['2']->getData());
- $this->assertNull($field['1']->getClientData());
- $this->assertSame('2', $field['2']->getClientData());
+ $this->assertNull($field['1']->getViewData());
+ $this->assertSame('2', $field['2']->getViewData());
}
public function testSubmitMultipleExpanded()
@@ -489,9 +489,9 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field['1']->getData());
$this->assertFalse($field['2']->getData());
$this->assertTrue($field['3']->getData());
- $this->assertSame('1', $field['1']->getClientData());
- $this->assertNull($field['2']->getClientData());
- $this->assertSame('3', $field['3']->getClientData());
+ $this->assertSame('1', $field['1']->getViewData());
+ $this->assertNull($field['2']->getViewData());
+ $this->assertSame('3', $field['3']->getViewData());
}
public function testOverrideChoices()
@@ -515,7 +515,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
- $this->assertSame('2', $field->getClientData());
+ $this->assertSame('2', $field->getViewData());
}
public function testGroupByChoices()
@@ -537,7 +537,7 @@ class EntityTypeTest extends TypeTestCase
$field->bind('2');
- $this->assertSame('2', $field->getClientData());
+ $this->assertSame('2', $field->getViewData());
$this->assertEquals(array(
'Group1' => array(1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar')),
'Group2' => array(3 => new ChoiceView($item3, '3', 'Baz')),
@@ -716,7 +716,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity1, $field->getData());
- $this->assertSame('foo', $field->getClientData());
+ $this->assertSame('foo', $field->getViewData());
}
public function testSubmitCompositeStringIdentifier()
@@ -738,7 +738,7 @@ class EntityTypeTest extends TypeTestCase
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity1, $field->getData());
- $this->assertSame('0', $field->getClientData());
+ $this->assertSame('0', $field->getViewData());
}
public function testGetManagerForClassIfNoEm()
diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php
index fa1aff10cf..0609fb675d 100644
--- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php
+++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php
@@ -27,7 +27,7 @@ class FormExtension extends \Twig_Extension
* This property is public so that it can be accessed directly from compiled
* templates without having to call a getter, which slightly decreases performance.
*
- * @var \Symfony\Component\Form\FormRendererInterface
+ * @var TwigRendererInterface
*/
public $renderer;
diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
index 39cdb43b49..3ab047c494 100644
--- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
@@ -147,8 +147,9 @@
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
+ {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %}
- {{ form_widget(form.hour, { 'attr': { 'size': '1' } }) }}{% if with_minutes %}:{{ form_widget(form.minute, { 'attr': { 'size': '1' } }) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1' } }) }}{% endif %}
+ {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
{% endif %}
{% endspaceless %}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 7cff079e82..606677f38b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -365,7 +365,7 @@ class FrameworkExtension extends Extension
$container->setParameter('templating.helper.code.file_link_format', isset($links[$ide]) ? $links[$ide] : $ide);
$container->setParameter('templating.helper.form.resources', $config['form']['resources']);
- $container->setParameter('templating.hinclude.default_template', $config['hinclude_default_template']);
+ $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']);
if ($container->getParameter('kernel.debug')) {
$loader->load('templating_debug.xml');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php b/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php
index da273cd7a7..82c6a0b2b7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php
@@ -40,7 +40,9 @@ class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer
*/
public function render($uri, Request $request, array $options = array())
{
- if (!$this->templating) {
+ // setting the templating cannot be done in the constructor
+ // as it would lead to an infinite recursion in the service container
+ if (!$this->hasTemplating()) {
$this->setTemplating($this->container->get('templating'));
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php
index 62424be57e..e24411cd74 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php
@@ -1,20 +1,21 @@
block($form, 'form_widget_simple'); ?>
+ array('size' => 1)) : array() ?>
block($form, 'widget_container_attributes') ?>>
widget($form['hour'], array('attr' => array('size' => 1)));
+ echo $view['form']->widget($form['hour'], $vars);
if ($with_minutes) {
echo ':';
- echo $view['form']->widget($form['minute'], array('attr' => array('size' => 1)));
+ echo $view['form']->widget($form['minute'], $vars);
}
if ($with_seconds) {
echo ':';
- echo $view['form']->widget($form['second'], array('attr' => array('size' => 1)));
+ echo $view['form']->widget($form['second'], $vars);
}
?>
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragments/ContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragments/ContainerAwareHIncludeFragmentRendererTest.php
new file mode 100644
index 0000000000..546d48bc0b
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragments/ContainerAwareHIncludeFragmentRendererTest.php
@@ -0,0 +1,30 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Bundle\FrameworkBundle\Tests\Fragment;
+
+use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
+use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer;
+use Symfony\Component\HttpFoundation\Request;
+
+class ContainerAwareHIncludeFragmentRendererTest extends TestCase
+{
+ public function testRender()
+ {
+ $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $container->expects($this->once())
+ ->method('get')
+ ->will($this->returnValue($this->getMock('\Twig_Environment')))
+ ;
+ $renderer = new ContainerAwareHIncludeFragmentRenderer($container);
+ $renderer->render('/', Request::create('/'));
+ }
+}
diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json
index 45c9320e8a..c41d1bdde1 100644
--- a/src/Symfony/Bundle/FrameworkBundle/composer.json
+++ b/src/Symfony/Bundle/FrameworkBundle/composer.json
@@ -26,7 +26,7 @@
"symfony/stopwatch": ">=2.2,<2.4-dev",
"symfony/templating": "~2.1",
"symfony/translation": ">=2.2,<2.4-dev",
- "doctrine/common": ">=2.2,<2.4-dev"
+ "doctrine/common": "~2.2"
},
"require-dev": {
"symfony/finder": "~2.0",
diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php
index 153b1fcc14..b4c3385934 100644
--- a/src/Symfony/Component/BrowserKit/Cookie.php
+++ b/src/Symfony/Component/BrowserKit/Cookie.php
@@ -30,6 +30,8 @@ class Cookie
'D, d M Y H:i:s T',
'D, d-M-y H:i:s T',
'D, d-M-Y H:i:s T',
+ 'D, d-m-y H:i:s T',
+ 'D, d-m-Y H:i:s T',
'D M j G:i:s Y',
'D M d H:i:s Y T',
);
@@ -205,6 +207,11 @@ class Cookie
}
}
+ // attempt a fallback for unusual formatting
+ if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
+ return $date->getTimestamp();
+ }
+
throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue));
}
diff --git a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php
index 13e343a901..be53eea417 100644
--- a/src/Symfony/Component/BrowserKit/Tests/CookieTest.php
+++ b/src/Symfony/Component/BrowserKit/Tests/CookieTest.php
@@ -56,9 +56,12 @@ class CookieTest extends \PHPUnit_Framework_TestCase
return array(
array('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'),
array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'),
+ array('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'),
+ array('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'),
array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'),
array('foo=bar; expires=Fri Jul 31 08:49:37 2020'),
array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''),
+ array('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'),
);
}
@@ -86,7 +89,7 @@ class CookieTest extends \PHPUnit_Framework_TestCase
public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid()
{
$this->setExpectedException('InvalidArgumentException');
- Cookie::FromString('foo=bar; expires=foo');
+ Cookie::FromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT');
}
public function testFromStringThrowsAnExceptionIfUrlIsNotValid()
diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php
index 2cdf98d0f2..34bbf11fb0 100644
--- a/src/Symfony/Component/DomCrawler/Link.php
+++ b/src/Symfony/Component/DomCrawler/Link.php
@@ -46,7 +46,7 @@ class Link
*/
public function __construct(\DOMNode $node, $currentUri, $method = 'GET')
{
- if (!in_array(substr($currentUri, 0, 4), array('http', 'file'))) {
+ if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
}
diff --git a/src/Symfony/Component/Form/ResolvedFormType.php b/src/Symfony/Component/Form/ResolvedFormType.php
index d889d0df5a..d20f3b390f 100644
--- a/src/Symfony/Component/Form/ResolvedFormType.php
+++ b/src/Symfony/Component/Form/ResolvedFormType.php
@@ -62,7 +62,9 @@ class ResolvedFormType implements ResolvedFormTypeInterface
// BC
if ($innerType instanceof AbstractType) {
/* @var AbstractType $innerType */
+ set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$innerType->setExtensions($typeExtensions);
+ restore_error_handler();
}
$this->innerType = $innerType;
diff --git a/src/Symfony/Component/Form/Resources/translations/validators.el.xlf b/src/Symfony/Component/Form/Resources/translations/validators.el.xlf
new file mode 100644
index 0000000000..ba2ced74b0
--- /dev/null
+++ b/src/Symfony/Component/Form/Resources/translations/validators.el.xlf
@@ -0,0 +1,19 @@
+
+
+
+
+
+ This form should not contain extra fields.
+ Αυτή η φόρμα δεν πρέπει να περιέχει επιπλέον πεδία.
+
+
+ The uploaded file was too large. Please try to upload a smaller file.
+ Το αρχείο είναι πολύ μεγάλο. Παρακαλούμε προσπαθήστε να ανεβάσετε ένα μικρότερο αρχείο.
+
+
+ The CSRF token is invalid. Please try to resubmit the form.
+ Το CSRF token δεν είναι έγκυρο. Παρακαλούμε δοκιμάστε να υποβάλετε τη φόρμα ξανά.
+
+
+
+
diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
index 6bffae3a6b..15e6530818 100644
--- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -1533,11 +1533,11 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[
./select
[@id="name_hour"]
- [@size="1"]
+ [not(@size)]
[./option[@value="4"][@selected="selected"]]
/following-sibling::select
[@id="name_minute"]
- [@size="1"]
+ [not(@size)]
[./option[@value="5"][@selected="selected"]]
]
[count(./select)=2]
@@ -1557,17 +1557,17 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[
./select
[@id="name_hour"]
- [@size="1"]
+ [not(@size)]
[./option[@value="4"][@selected="selected"]]
[count(./option)>23]
/following-sibling::select
[@id="name_minute"]
- [@size="1"]
+ [not(@size)]
[./option[@value="5"][@selected="selected"]]
[count(./option)>59]
/following-sibling::select
[@id="name_second"]
- [@size="1"]
+ [not(@size)]
[./option[@value="6"][@selected="selected"]]
[count(./option)>59]
]
@@ -1618,6 +1618,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[@type="time"]
[@name="name"]
[@value="04:05"]
+ [not(@size)]
'
);
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
index fae4ae3e5b..2d0bf30455 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php
@@ -601,9 +601,11 @@ class FormTypeTest extends TypeTestCase
// BC
public function testPropertyPathFalseImpliesDefaultNotMapped()
{
+ set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$form = $this->factory->createNamed('name', 'form', null, array(
'property_path' => false,
));
+ restore_error_handler();
$this->assertEquals(new PropertyPath('name'), $form->getPropertyPath());
$this->assertFalse($form->getConfig()->getMapped());
@@ -661,4 +663,15 @@ class FormTypeTest extends TypeTestCase
$this->assertSame('foo', $view->vars['data']);
$this->assertSame('bar', $view->vars['value']);
}
+
+ // https://github.com/symfony/symfony/issues/6862
+ public function testPassZeroLabelToView()
+ {
+ $view = $this->factory->create('form', null, array(
+ 'label' => '0'
+ ))
+ ->createView();
+
+ $this->assertSame('0', $view->vars['label']);
+ }
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php
index d3e2932c01..9eadaac2c4 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php
@@ -42,7 +42,7 @@ class MoneyTypeTest extends LocalizedTestCase
$view1 = $form1->createView();
$view2 = $form2->createView();
- $this->assertSame('{{ widget }} £', $view1->get('money_pattern'));
- $this->assertSame('{{ widget }} €', $view2->get('money_pattern'));
+ $this->assertSame('{{ widget }} £', $view1->vars['money_pattern']);
+ $this->assertSame('{{ widget }} €', $view2->vars['money_pattern']);
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
index 72270c7f9a..1277097103 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
@@ -231,7 +231,7 @@ class TimeTypeTest extends LocalizedTestCase
$form->setData(new \DateTime('03:04:05 UTC'));
- $this->assertEquals(array('hour' => 3), $form->getClientData());
+ $this->assertEquals(array('hour' => 3), $form->getViewData());
}
public function testSetDataWithSeconds()
diff --git a/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php b/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php
index fad0616280..536ff4c824 100644
--- a/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php
+++ b/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php
@@ -32,13 +32,6 @@ abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase
$this->factory = Forms::createFormFactoryBuilder()
->addExtensions($this->getExtensions())
->getFormFactory();
-
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
- }
-
- protected function tearDown()
- {
- restore_error_handler();
}
protected function getExtensions()
diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php
index 0c4e0e9372..d0b549b4ee 100644
--- a/src/Symfony/Component/HttpFoundation/Response.php
+++ b/src/Symfony/Component/HttpFoundation/Response.php
@@ -253,6 +253,16 @@ class Response
$this->headers->set('expires', -1);
}
+ /**
+ * Check if we need to remove Cache-Control for ssl encrypted downloads when using IE < 9
+ * @link http://support.microsoft.com/kb/323308
+ */
+ if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
+ if(intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) {
+ $this->headers->remove('Cache-Control');
+ }
+ }
+
return $this;
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
index 6ca569c3ea..28b9d53732 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -326,6 +326,75 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
}
+ public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE()
+ {
+ // Check for HTTPS and IE 8
+ $request = new Request();
+ $request->server->set('HTTPS', true);
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertFalse($response->headers->has('Cache-Control'));
+
+ // Check for IE 10 and HTTPS
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for IE 9 and HTTPS
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for IE 9 and HTTP
+ $request->server->set('HTTPS', false);
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for IE 8 and HTTP
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for non-IE and HTTPS
+ $request->server->set('HTTPS', true);
+ $request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17');
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+
+ // Check for non-IE and HTTP
+ $request->server->set('HTTPS', false);
+
+ $response = new Response();
+ $response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"');
+ $response->prepare($request);
+
+ $this->assertTrue($response->headers->has('Cache-Control'));
+ }
+
public function testPrepareDoesNothingIfContentTypeIsSet()
{
$response = new Response('foo');
diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md
index d6f8886811..fc47662b43 100644
--- a/src/Symfony/Component/HttpKernel/CHANGELOG.md
+++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md
@@ -4,6 +4,7 @@ CHANGELOG
2.2.0
-----
+ * [BC BREAK] the path info for sub-request is now always _fragment (or whatever you configured instead of the default)
* added Symfony\Component\HttpKernel\EventListener\FragmentListener
* added Symfony\Component\HttpKernel\UriSigner
* added Symfony\Component\HttpKernel\FragmentRenderer and rendering strategies (in Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface)
diff --git a/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
index 529314b86d..f3cb804832 100644
--- a/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
+++ b/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php
@@ -12,7 +12,9 @@
namespace Symfony\Component\HttpKernel\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RequestContextAwareInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -25,6 +27,7 @@ class LocaleListener implements EventSubscriberInterface
{
private $router;
private $defaultLocale;
+ private $locales = array();
public function __construct($defaultLocale = 'en', RequestContextAwareInterface $router = null)
{
@@ -32,19 +35,24 @@ class LocaleListener implements EventSubscriberInterface
$this->router = $router;
}
+ public function onKernelResponse(FilterResponseEvent $event)
+ {
+ array_shift($this->locales);
+
+ // setting back the locale to the previous value
+ $locale = isset($this->locales[0]) ? $this->locales[0] : $this->defaultLocale;
+ $request = $event->getRequest();
+ $this->setLocale($request, $locale);
+ }
+
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
$request->setDefaultLocale($this->defaultLocale);
+ $this->setLocale($request, $request->attributes->get('_locale', $this->defaultLocale));
- if ($locale = $request->attributes->get('_locale')) {
- $request->setLocale($locale);
- }
-
- if (null !== $this->router) {
- $this->router->getContext()->setParameter('_locale', $request->getLocale());
- }
+ array_unshift($this->locales, $request->getLocale());
}
public static function getSubscribedEvents()
@@ -52,6 +60,16 @@ class LocaleListener implements EventSubscriberInterface
return array(
// must be registered after the Router to have access to the _locale
KernelEvents::REQUEST => array(array('onKernelRequest', 16)),
+ KernelEvents::RESPONSE => 'onKernelResponse',
);
}
+
+ private function setLocale(Request $request, $locale)
+ {
+ $request->setLocale($locale);
+
+ if (null !== $this->router) {
+ $this->router->getContext()->setParameter('_locale', $request->getLocale());
+ }
+ }
}
diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
index 1f6c2634bf..fafa76368c 100644
--- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
+++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php
@@ -56,6 +56,16 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
$this->templating = $templating;
}
+ /**
+ * Checks if a templating engine has been set.
+ *
+ * @return Boolean true if the templating engine has been set, false otherwise
+ */
+ public function hasTemplating()
+ {
+ return null !== $this->templating;
+ }
+
/**
* {@inheritdoc}
*
@@ -73,6 +83,9 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
$uri = $this->signer->sign($this->generateFragmentUri($uri, $request));
}
+ // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
+ $uri = str_replace('&', '&', $uri);
+
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
if (null !== $this->templating && $template && $this->templateExists($template)) {
$content = $this->templating->render($template);
diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
index 76fd720a45..1e77374901 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php
@@ -38,7 +38,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
{
$strategy = new HIncludeFragmentRenderer(null, new UriSigner('foo'));
- $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
+ $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
}
public function testRenderWithUri()
diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json
index 16c1b8c072..dd4eecfb91 100644
--- a/src/Symfony/Component/Security/composer.json
+++ b/src/Symfony/Component/Security/composer.json
@@ -25,7 +25,7 @@
"symfony/form": "~2.0",
"symfony/routing": ">=2.2,<2.4-dev",
"symfony/validator": ">=2.2,<2.4-dev",
- "doctrine/common": ">=2.2,<2.4-dev",
+ "doctrine/common": "~2.2",
"doctrine/dbal": "~2.2",
"psr/log": "~1.0"
},