dns_get_record() warning on localhost
-
I am running WAMP64 on my Windows 11 machine so WordPress is running on localhost.
When viewing the Dashboard/Plugins page I get two warnings from Jetpack:
Warning dns_get_record(): DNS Query failed
- wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-host.php:149
Warning foreach() argument must be of type array|object, bool given - wp-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-status/src/class-host.php:151This is because
dns_get_record()
returns false and the subsequent code does not check for this.Here’s a one line patch that fixes the second warning (the first likely shows beca
--- class-host.orig.php 2025-02-07 15:21:19.169669900 +0000
+++ class-host.php 2025-02-07 15:21:54.700851100 +0000
@@ -147,6 +147,7 @@
}
$dns_records = dns_get_record( $domain, DNS_NS ); // Fetches the DNS records of type NS (Name Server)
+ if ( false == $dns_records ) { return array(); }
$nameservers = array();
foreach ( $dns_records as $record ) {
if ( isset( $record['target'] ) ) {
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.