Skip to content

Commit 52969e9

Browse files
committed
simplify error handling for dns_get_record()
1 parent 87b8b85 commit 52969e9

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/Validation/DNSGetRecordWrapper.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,7 @@ class DNSGetRecordWrapper
1212
*/
1313
public function getRecords(string $host, int $type): DNSRecords
1414
{
15-
// A workaround to fix https://bugs.php.net/bug.php?id=73149
16-
set_error_handler(
17-
static function (int $errorLevel, string $errorMessage): never {
18-
throw new \RuntimeException("Unable to get DNS record for the host: $errorMessage");
19-
}
20-
);
21-
try {
22-
// Get all MX, A and AAAA DNS records for host
23-
return new DNSRecords(dns_get_record($host, $type));
24-
} catch (\RuntimeException $exception) {
25-
return new DNSRecords([], true);
26-
} finally {
27-
restore_error_handler();
28-
}
15+
$result = @dns_get_record($host, $type);
16+
return new DNSRecords($result === false ? [] : $result);
2917
}
3018
}

0 commit comments

Comments
 (0)