8000 Removes deprecation message · GromNaN/symfony@0501d56 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 0501d56

Browse files
committed
Removes deprecation message
1 parent 2ae7df4 commit 0501d56

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ public function onSubmit(FormEvent $event)
3636
{
3737
$data = $event->getData();
3838

39-
if ($this->defaultProtocol && $data && \is_string($data) && !preg_match('~^[\w+.-]+://~', $data)) {
40-
// Detect email & non-url
41-
if (preg_match('~^([^:/?@]++@|[^./]+$)~', $data)) {
42-
trigger_deprecation('symfony/form', '5.4', 'Form type "url", does not add a default protocol to urls that looks like emails or does not contain a dot or slash.');
43-
44-
return;
45-
}
39+
if ($this->defaultProtocol && $data && \is_string($data)
40+
&& !preg_match('~^[\w+.-]+://~', $data)
41+
// skip email & non-url values
42+
&& !preg_match('~^([^:/?@]++@|[^./]+$)~', $data)
43+
) {
4644
$event->setData($this->defaultProtocol.'://'.$data);
4745
}
4846
}

src/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public function provideUrlsWithSupportedProtocols()
4444
['h323://foo'],
4545
['iris.beep://foo'],
4646
['foo+bar://foo'],
47+
['fabien@symfony.com'],
48+
['foo'],
4749
];
4850
}
4951

@@ -60,29 +62,4 @@ public function testSkipOtherProtocol($url)
6062

6163
$this->assertEquals($url, $event->getData());
6264
}
63-
64-
/**
65-
* @group legacy
66-
* @dataProvider provideNonUrls
67-
*/
68-
public function testDeprecatedFixEmail($url)
69-
{
70-
$this->expectDeprecation('Since symfony/form 5.4: Form type "url", does not add a default protocol to urls that looks like emails or does not contain a dot or slash.');
71-
72-
$form = new Form(new FormConfigBuilder('name', null, new EventDispatcher()));
73-
$event = new FormEvent($form, $url);
74-
75-
$filter = new FixUrlProtocolListener('http');
76-
$filter->onSubmit($event);
77-
78-
$this->assertEquals($url, $event->getData());
79-
}
80-
81-
public function provideNonUrls()
82-
{
83-
return [
84-
['fabien@symfony.com'],
85-
['foo'],
86-
];
87-
}
8865
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testThrowExceptionIfDefaultProtocolIsInvalid()
9393
]);
9494
}
9595

96-
public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty', $expectedData = 'http://empty')
96+
public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty.com', $expectedData = 'http://empty.com')
9797
{
9898
$form = $this->factory->create(static::TESTED_TYPE, null, array_merge($this->getTestOptions(), [
9999
'empty_data' => $emptyData,

0 commit comments

Comments
 (0)
0