Skip to content

Commit e514cea

Browse files
committed
Merge branch '2.7'
* 2.7: added type-hint [Security] removed usage of the deprecated SecurityContextInterface [Form] fixed deprecation triggers, removed usage of deprecated features [EventDispatcher] fixed deprecation notices in the EventDispatcher Component [HttpFoundation] maked a test as being for deprecated feature added missing error_reporting [Yaml] maked a test as being for deprecated feature [Yaml] removed deprecation notices on internal constant [Security] moved test files into the right place [HttpKernel] fixed deprecation notices for ESI classes [Form] moved a deprecation notice [Form] fixed the CSRF extension to allow using only the new interfaces [Form] tweaked a deprecation message [Validator] Add a Russian translation for the checkDNS option in the URL validator [Validator] Add a Slovenian translation for the checkDNS option in the URL validator [Validator] Add a Polish translation for the checkDNS option in the URL validator. fixed typo added missing support for factories in console descriptions [FrameworkBundle] fixed missing information in some descriptors Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/SecurityBundle/composer.json src/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php src/Symfony/Component/Yaml/Tests/YamlTest.php
2 parents 1ea742a + bebd6b3 commit e514cea

File tree

9 files changed

+39
-15
lines changed

9 files changed

+39
-15
lines changed

Exception/AlreadyBoundException.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Exception;
1313

14-
trigger_error('The '.__NAMESPACE__.'\AlreadyBoundException class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
15-
1614
/**
1715
* Alias of {@link AlreadySubmittedException}.
1816
*
@@ -21,4 +19,12 @@
2119
*/
2220
class AlreadyBoundException extends LogicException
2321
{
22+
public function __construct($message = '', $code = 0, \Exception $previous = null)
23+
{
24+
if (__CLASS__ === get_class($this)) {
25+
trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED);
26+
}
27+
28+
parent::__construct($message, $code, $previous);
29+
}
2430
}

Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
1313

14-
trigger_error('The '.__NAMESPACE__.'\CsrfTokenManagerAdapter is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
15-
1614
use Symfony\Component\Security\Csrf\CsrfToken;
1715
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
1816

@@ -36,8 +34,12 @@ public function __construct(CsrfTokenManagerInterface $tokenManager)
3634
$this->tokenManager = $tokenManager;
3735
}
3836

39-
public function getTokenManager()
37+
public function getTokenManager($triggerDeprecationError = true)
4038
{
39+
if ($triggerDeprecationError) {
40+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
41+
}
42+
4143
return $this->tokenManager;
4244
}
4345

@@ -46,6 +48,8 @@ public function getTokenManager()
4648
*/
4749
public function generateCsrfToken($intention)
4850
{
51+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
52+
4953
return $this->tokenManager->getToken($intention)->getValue();
5054
}
5155

@@ -54,6 +58,8 @@ public function generateCsrfToken($intention)
5458
*/
5559
public function isCsrfTokenValid($intention, $token)
5660
{
61+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
62+
5763
return $this->tokenManager->isTokenValid(new CsrfToken($intention, $token));
5864
}
5965
}

Extension/Csrf/Type/FormTypeCsrfExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
128128

129129
// BC clause for the "csrf_provider" option
130130
$csrfTokenManager = function (Options $options) {
131+
if ($options['csrf_provider'] instanceof CsrfTokenManagerInterface) {
132+
return $options['csrf_provider'];
133+
}
134+
131135
return $options['csrf_provider'] instanceof CsrfTokenManagerAdapter
132-
? $options['csrf_provider']->getTokenManager()
136+
? $options['csrf_provider']->getTokenManager(false)
133137
: new CsrfProviderAdapter($options['csrf_provider']);
134138
};
135139

@@ -139,7 +143,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
139143
'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.',
140144
'csrf_token_manager' => $csrfTokenManager,
141145
'csrf_token_id' => $csrfTokenId,
142-
'csrf_provider' => new CsrfTokenManagerAdapter($this->defaultTokenManager),
146+
'csrf_provider' => $this->defaultTokenManager,
143147
'intention' => null,
144148
));
145149
}

Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form
127127
$scope->addError(new FormError(
128128
$violation->getMessage(),
129129
$violation->getMessageTemplate(),
130-
$violation->getMessageParameters(),
131-
$violation->getMessagePluralization(),
130+
$violation->getParameters(),
131+
$violation->getPlural(),
132132
$violation
133133
));
134134
}

Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ public function getErrors($deep = false, $flatten = true)
848848
*/
849849
public function getErrorsAsString($level = 0)
850850
{
851-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the Form::getErrors(true, false) method instead and cast the result to a string.', E_USER_DEPRECATED);
851+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use (string) Form::getErrors(true, false) instead.', E_USER_DEPRECATED);
852852

853853
return self::indent((string) $this->getErrors(true, false), $level);
854854
}

Tests/CompoundFormTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,10 @@ public function testSubmitGetRequestWithEmptyRootFormName()
787787
$this->assertEquals(array('extra' => 'data'), $form->getExtraData());
788788
}
789789

790-
public function testGetErrorsAsStringDeep()
790+
public function testLegacyGetErrorsAsStringDeep()
791791
{
792+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
793+
792794
$parent = $this->getBuilder()
793795
->setCompound(true)
794796
->setDataMapper($this->getDataMapper())
@@ -806,8 +808,10 @@ public function testGetErrorsAsStringDeep()
806808
);
807809
}
808810

809-
public function testGetErrorsAsStringDeepWithIndentation()
811+
public function testLegacyGetErrorsAsStringDeepWithIndentation()
810812
{
813+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
814+
811815
$parent = $this->getBuilder()
812816
->setCompound(true)
813817
->setDataMapper($this->getDataMapper())

Tests/Extension/Core/Type/FormTypeTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,10 @@ public function testPassZeroLabelToView()
637637
$this->assertSame('0', $view->vars['label']);
638638
}
639639

640-
public function testCanGetErrorsWhenButtonInForm()
640+
public function testLegacyCanGetErrorsWhenButtonInForm()
641641
{
642+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
643+
642644
$builder = $this->factory->createBuilder('form', null, array(
643645
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
644646
'required' => false,

Tests/Extension/Validator/Constraints/FormValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public function testNoViolationIfAllowExtraData()
575575
->add($this->getBuilder('child'))
576576
->getForm();
577577

578-
$form->bind(array('foo' => 'bar'));
578+
$form->submit(array('foo' => 'bar'));
579579

580580
$context->expects($this->never())
581581
->method('addViolation');

Tests/SimpleFormTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,10 @@ public function testCreateViewWithExplicitParent()
732732
$this->assertSame($view, $form->createView($parentView));
733733
}
734734

735-
public function testGetErrorsAsString()
735+
public function testLegacyGetErrorsAsString()
736736
{
737+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
738+
737739
$this->form->addError(new FormError('Error!'));
738740

739741
$this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString());

0 commit comments

Comments
 (0)