Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c48ae25

Browse filesBrowse files
committed
Merge branch '2.4' into 2.5
* 2.4: [Form] Removed constructor argument from FormTypeHttpFoundationExtension for forward compatibility with 2.5 [Validator] Simplified testing of violations remove obsolete test file [FrameworkBundle] output failed matched path for clarification bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider [Validator] Fixed StaticMethodLoaderTest to actually test something [Form] Fixed ValidatorTypeGuesser to guess properties without constraints not to be required Use request format from request in twig ExceptionController fixed bug added the possibility to return null from SimplePreAuthenticationListener [Form] Moved POST_MAX_SIZE validation from FormValidator to request handler [Form] Add a form error if post_max_size has been reached. Response::isNotModified returns true when If-Modified-Since is later than Last-Modified [WebProfilerBundle] turbolinks compatibility Conflicts: src/Symfony/Component/Form/Extension/Core/Type/FormType.php src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
2 parents 1c254a4 + efb1237 commit c48ae25
Copy full SHA for c48ae25

File tree

Expand file treeCollapse file tree

59 files changed

+932
-628
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

59 files changed

+932
-628
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+16-4Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ public function testValidateUniqueness()
165165

166166
$this->validator->validate($entity2, $constraint);
167167

168-
$this->assertViolation('myMessage', array(), 'property.path.name', 'Foo');
168+
$this->buildViolation('myMessage')
169+
->atPath('property.path.name')
170+
->setInvalidValue('Foo')
171+
->assertRaised();
169172
}
170173

171174
public function testValidateCustomErrorPath()
@@ -185,7 +188,10 @@ public function testValidateCustomErrorPath()
185188

186189
$this->validator->validate($entity2, $constraint);
187190

188-
$this->assertViolation('myMessage', array(), 'property.path.bar', 'Foo');
191+
$this->buildViolation('myMessage')
192+
->atPath('property.path.bar')
193+
->setInvalidValue('Foo')
194+
->assertRaised();
189195
}
190196

191197
public function testValidateUniquenessWithNull()
@@ -233,7 +239,10 @@ public function testValidateUniquenessWithIgnoreNull()
233239

234240
$this->validator->validate($entity2, $constraint);
235241

236-
$this->assertViolation('myMessage', array(), 'property.path.name', 'Foo');
242+
$this->buildViolation('myMessage')
243+
->atPath('property.path.name')
244+
->setInvalidValue('Foo')
245+
->assertRaised();
237246
}
238247

239248
public function testValidateUniquenessAfterConsideringMultipleQueryResults()
@@ -352,7 +361,10 @@ public function testAssociatedEntity()
352361

353362
$this->validator->validate($associated2, $constraint);
354363

355-
$this->assertViolation('myMessage', array(), 'property.path.single', 1);
364+
$this->buildViolation('myMessage')
365+
->atPath('property.path.single')
366+
->setInvalidValue(1)
367+
->assertRaised();
356368
}
357369

358370
public function testAssociatedEntityWithNull()

‎src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
107107
}
108108

109109
if (!$matches) {
110-
$output->writeln('<fg=red>None of the routes match</>');
110+
$output->writeln(sprintf('<fg=red>None of the routes match the path "%s"</>', $input->getArgument('path_info')));
111111

112112
return 1;
113113
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/TestCaseMethod.tpl

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/TestCaseMethod.tpl
-47Lines changed: 0 additions & 47 deletions
This file was deleted.

‎src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,19 @@ public function __construct(\Twig_Environment $twig, $debug)
3939
* @param Request $request The request
4040
* @param FlattenException $exception A FlattenException instance
4141
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
42-
* @param string $_format The format to use for rendering (html, xml, ...)
4342
*
4443
* @return Response
4544
*
4645
* @throws \InvalidArgumentException When the exception template does not exist
4746
*/
48-
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
47+
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
4948
{
5049
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
5150

5251
$code = $exception->getStatusCode();
5352

5453
return new Response($this->twig->render(
55-
$this->findTemplate($request, $_format, $code, $this->debug),
54+
$this->findTemplate($request, $request->getRequestFormat(), $code, $this->debug),
5655
array(
5756
'status_code' => $code,
5857
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- START of Symfony2 Web Debug Toolbar -->
22
{% if 'normal' != position %}
3-
<div id="sfMiniToolbar-{{ token }}" class="sf-minitoolbar">
3+
<div id="sfMiniToolbar-{{ token }}" class="sf-minitoolbar" data-no-turbolink>
44
<a href="javascript:void(0);" title="Show Symfony toolbar" onclick="
55
var elem = this.parentNode;
66
if (elem.style.display == 'none') {
@@ -24,7 +24,7 @@
2424
<div id="sfToolbarClearer-{{ token }}" style="clear: both; height: 38px;"></div>
2525
{% endif %}
2626

27-
<div id="sfToolbarMainContent-{{ token }}" class="sf-toolbarreset">
27+
<div id="sfToolbarMainContent-{{ token }}" class="sf-toolbarreset" data-no-turbolink>
2828
{% for name, template in templates %}
2929
{{ template.renderblock('toolbar', {
3030
'collector': profile.getcollector(name),

‎src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/FormType.php
+20-20Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5656
->setDataLocked($isDataOptionSet)
5757
->setDataMapper($options['compound'] ? new PropertyPathMapper($this->propertyAccessor) : null)
5858
->setMethod($options['method'])
59-
->setAction($options['action'])
60-
;
59+
->setAction($options['action']);
6160

6261
if ($options['trim']) {
6362
$builder->addEventSubscriber(new TrimListener());
@@ -187,26 +186,27 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
187186
};
188187

189188
$resolver->setDefaults(array(
190-
'data_class' => $dataClass,
191-
'empty_data' => $emptyData,
192-
'trim' => true,
193-
'required' => true,
194-
'read_only' => false,
195-
'max_length' => null,
196-
'pattern' => null,
197-
'property_path' => null,
198-
'mapped' => true,
199-
'by_reference' => true,
200-
'error_bubbling' => $errorBubbling,
201-
'label_attr' => array(),
202-
'virtual' => null,
203-
'inherit_data' => $inheritData,
204-
'compound' => true,
205-
'method' => 'POST',
189+
'data_class' => $dataClass,
190+
'empty_data' => $emptyData,
191+
'trim' => true,
192+
'required' => true,
193+
'read_only' => false,
194+
'max_length' => null,
195+
'pattern' => null,
196+
'property_path' => null,
197+
'mapped' => true,
198+
'by_reference' => true,
199+
'error_bubbling' => $errorBubbling,
200+
'label_attr' => array(),
201+
'virtual' => null,
202+
'inherit_data' => $inheritData,
203+
'compound' => true,
204+
'method' => 'POST',
206205
// According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt)
207206
// section 4.2., empty URIs are considered same-document references
208-
'action' => '',
209-
'attr' => $defaultAttr,
207+
'action' => '',
208+
'attr' => $defaultAttr,
209+
'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
210210
));
211211

212212
$resolver->setAllowedTypes(array(

‎src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Component\Form\Extension\HttpFoundation;
1313

1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
15+
use Symfony\Component\Form\FormError;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\RequestHandlerInterface;
18+
use Symfony\Component\Form\Util\ServerParams;
1719
use Symfony\Component\HttpFoundation\Request;
1820

1921
/**
@@ -24,6 +26,19 @@
2426
*/
2527
class HttpFoundationRequestHandler implements RequestHandlerInterface
2628
{
29+
/**
30+
* @var ServerParams
31+
*/
32+
private $serverParams;
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function __construct(ServerParams $serverParams = null)
38+
{
39+
$this->serverParams = $serverParams ?: new ServerParams();
40+
}
41+
2742
/**
2843
* {@inheritdoc}
2944
*/
@@ -53,6 +68,25 @@ public function handleRequest(FormInterface $form, $request = null)
5368
$data = $request->query->get($name);
5469
}
5570
} else {
71+
// Mark the form with an error if the uploaded size was too large
72+
// This is done here and not in FormValidator because $_POST is
73+
// empty when that error occurs. Hence the form is never submitted.
74+
$contentLength = $this->serverParams->getContentLength();
75+
$maxContentLength = $this->serverParams->getPostMaxSize();
76+
77+
if (!empty($maxContentLength) && $contentLength > $maxContentLength) {
78+
// Submit the form, but don't clear the default values
79+
$form->submit(null, false);
80+
81+
$form->addError(new FormError(
82+
$form->getConfig()->getOption('post_max_size_message'),
83+
null,
84+
array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize())
85+
));
86+
87+
return;
88+
}
89+
5690
if ('' === $name) {
5791
$params = $request->request->all();
5892
$files = $request->files->all();

‎src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
-40Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form\Extension\Validator\Constraints;
1313

1414
use Symfony\Component\Form\FormInterface;
15-
use Symfony\Component\Form\Extension\Validator\Util\ServerParams;
1615
use Symfony\Component\Validator\Constraint;
1716
use Symfony\Component\Validator\ConstraintValidator;
1817
use Symfony\Component\Validator\Context\ExecutionContextInterface;
@@ -23,22 +22,6 @@
2322
*/
2423
class FormValidator extends ConstraintValidator
2524
{
26-
/**
27-
* @var ServerParams
28-
*/
29-
private $serverParams;
30-
31-
/**
32-
* Creates a validator with the given server parameters.
33-
*
34-
* @param ServerParams $params The server parameters. Default
35-
* parameters are created if null.
36-
*/
37-
public function __construct(ServerParams $params = null)
38-
{
39-
$this->serverParams = $params ?: new ServerParams();
40-
}
41-
4225
/**
4326
* {@inheritdoc}
4427
*/
@@ -151,29 +134,6 @@ public function validate($form, Constraint $constraint)
151134
);
152135
}
153136
}
154-
155-
// Mark the form with an error if the uploaded size was too large
156-
$length = $this->serverParams->getContentLength();
157-
158-
if ($form->isRoot() && null !== $length) {
159-
$max = $this->serverParams->getPostMaxSize();
160-
161-
if (!empty($max) && $length > $max) {
162-
if ($this->context instanceof ExecutionContextInterface) {
163-
$this->context->buildViolation($config->getOption('post_max_size_message'))
164-
->setParameter('{{ max }}', $this->serverParams->getNormalizedIniPostMaxSize())
165-
->setInvalidValue($length)
166-
->addViolation();
167-
} else {
168-
// 2.4 API
169-
$this->context->addViolation(
170-
$config->getOption('post_max_size_message'),
171-
array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()),
172-
$length
173-
);
174-
}
175-
}
176-
}
177137
}
178138

179139
/**

‎src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
7474
'invalid_message' => 'This value is not valid.',
7575
'invalid_message_parameters' => array(),
7676
'extra_fields_message' => 'This form should not contain extra fields.',
77-
'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
7877
));
7978

8079
$resolver->setNormalizers(array(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.