Skip to content

Navigation Menu

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 38b946e

Browse filesBrowse files
committed
feature #25516 [Validator] Deprecated "checkDNS" option in Url constraint (ro0NL)
This PR was squashed before being merged into the 4.1-dev branch (closes #25516). Discussion ---------- [Validator] Deprecated "checkDNS" option in Url constraint | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #23538 | License | MIT | Doc PR | symfony/symfony-docs#8921 Commits ------- 70d15ca [Validator] Deprecated "checkDNS" option in Url constraint
2 parents 8c33cd4 + 70d15ca commit 38b946e
Copy full SHA for 38b946e

File tree

5 files changed

+86
-1
lines changed
Filter options

5 files changed

+86
-1
lines changed

‎UPGRADE-4.1.md

Copy file name to clipboardExpand all lines: UPGRADE-4.1.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Validator
3232

3333
* The `Email::__construct()` 'strict' property is deprecated and will be removed in 5.0. Use 'mode'=>"strict" instead.
3434
* Calling `EmailValidator::__construct()` method with a boolean parameter is deprecated and will be removed in 5.0, use `EmailValidator("strict")` instead.
35+
* Deprecated the `checkDNS` and `dnsMessage` options of the `Url` constraint. They will be removed in 5.0.
3536

3637
Workflow
3738
--------

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Validator
3030

3131
* The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead.
3232
* Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead.
33-
33+
* Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint.
3434

3535
Workflow
3636
--------

‎src/Symfony/Component/Validator/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.1.0
5+
-----
6+
7+
* Deprecated the `checkDNS` and `dnsMessage` options of the `Url` constraint. They will be removed in 5.0.
8+
49
4.0.0
510
-----
611

‎src/Symfony/Component/Validator/Constraints/Url.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Url.php
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,57 @@
2121
*/
2222
class Url extends Constraint
2323
{
24+
/**
25+
* @deprecated since Symfony 4.1, to be removed in 5.0
26+
*/
2427
const CHECK_DNS_TYPE_ANY = 'ANY';
28+
/**
29+
* @deprecated since Symfony 4.1, to be removed in 5.0
30+
*/
2531
const CHECK_DNS_TYPE_NONE = false;
32+
/**
33+
* @deprecated since Symfony 4.1, to be removed in 5.0
34+
*/
2635
const CHECK_DNS_TYPE_A = 'A';
36+
/**
37+
* @deprecated since Symfony 4.1, to be removed in 5.0
38+
*/
2739
const CHECK_DNS_TYPE_A6 = 'A6';
40+
/**
41+
* @deprecated since Symfony 4.1, to be removed in 5.0
42+
*/
2843
const CHECK_DNS_TYPE_AAAA = 'AAAA';
44+
/**
45+
* @deprecated since Symfony 4.1, to be removed in 5.0
46+
*/
2947
const CHECK_DNS_TYPE_CNAME = 'CNAME';
48+
/**
49+
* @deprecated since Symfony 4.1, to be removed in 5.0
50+
*/
3051
const CHECK_DNS_TYPE_MX = 'MX';
52+
/**
53+
* @deprecated since Symfony 4.1, to be removed in 5.0
54+
*/
3155
const CHECK_DNS_TYPE_NAPTR = 'NAPTR';
56+
/**
57+
* @deprecated since Symfony 4.1, to be removed in 5.0
58+
*/
3259
const CHECK_DNS_TYPE_NS = 'NS';
60+
/**
61+
* @deprecated since Symfony 4.1, to be removed in 5.0
62+
*/
3363
const CHECK_DNS_TYPE_PTR = 'PTR';
64+
/**
65+
* @deprecated since Symfony 4.1, to be removed in 5.0
66+
*/
3467
const CHECK_DNS_TYPE_SOA = 'SOA';
68+
/**
69+
* @deprecated since Symfony 4.1, to be removed in 5.0
70+
*/
3571
const CHECK_DNS_TYPE_SRV = 'SRV';
72+
/**
73+
* @deprecated since Symfony 4.1, to be removed in 5.0
74+
*/
3675
const CHECK_DNS_TYPE_TXT = 'TXT';
3776

3877
const INVALID_URL_ERROR = '57c2f299-1154-4870-89bb-ef3b1f5ad229';
@@ -42,7 +81,27 @@ class Url extends Constraint
4281
);
4382

4483
public $message = 'This value is not a valid URL.';
84+
/**
85+
* @deprecated since Symfony 4.1, to be removed in 5.0
86+
*/
4587
public $dnsMessage = 'The host could not be resolved.';
4688
public $protocols = array('http', 'https');
89+
/**
90+
* @deprecated since Symfony 4.1, to be removed in 5.0
91+
*/
4792
public $checkDNS = self::CHECK_DNS_TYPE_NONE;
93+
94+
public function __construct($options = null)
95+
{
96+
if (is_array($options)) {
97+
if (array_key_exists('checkDNS', $options)) {
98+
@trigger_error(sprintf('The "checkDNS" option in "%s" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.', self::class), E_USER_DEPRECATED);
99+
}
100+
if (array_key_exists('dnsMessage', $options)) {
101+
@trigger_error(sprintf('The "dnsMessage" option in "%s" is deprecated since Symfony 4.1 and will be removed in 5.0.', self::class), E_USER_DEPRECATED);
102+
}
103+
}
104+
105+
parent::__construct($options);
106+
}
48107
}

‎src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ public function getValidCustomUrls()
200200
/**
201201
* @dataProvider getCheckDns
202202
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
203+
* @group legacy
204+
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
203205
*/
204206
public function testCheckDns($violation)
205207
{
@@ -230,6 +232,8 @@ public function getCheckDns()
230232
/**
231233
* @dataProvider getCheckDnsTypes
232234
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
235+
* @group legacy
236+
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
233237
*/
234238
public function testCheckDnsByType($type)
235239
{
@@ -266,6 +270,9 @@ public function getCheckDnsTypes()
266270
/**
267271
* @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException
268272
* @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts
273+
* @group legacy
274+
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
275+
* @expectedDeprecation The "dnsMessage" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0.
269276
*/
270277
public function testCheckDnsWithInvalidType()
271278
{
@@ -278,6 +285,19 @@ public function testCheckDnsWithInvalidType()
278285

279286
$this->validator->validate('http://example.com', $constraint);
280287
}
288+
289+
/**
290+
* @group legacy
291+
* @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1 and will be removed in 5.0. Its false-positive rate is too high to be relied upon.
292+
*/
293+
public function testCheckDnsOptionIsDeprecated()
294+
{
295+
$constraint = new Url(array(
296+
'checkDNS' => Url::CHECK_DNS_TYPE_NONE,
297+
));
298+
299+
$this->validator->validate('http://example.com', $constraint);
300+
}
281301
}
282302

283303
class EmailProvider

0 commit comments

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