• Resolved daymobrew

    (@daymobrew)


    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:151

    This 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)
  • Plugin Support Bruce (a11n)

    (@bruceallen)

    Happiness Engineer

    Hi @daymobrew

    Just checking, are you using Jetpack in Offline mode?

    Thread Starter daymobrew

    (@daymobrew)

    Yes, it is in offline mode. The Settings page says:

    Currently in Offline Mode (some features are disabled) because: Your site URL is a known local development environment URL

    Plugin Support Alin (a11n)

    (@alinclamba)

    Hi @daymobrew,

    Thanks for your confirmation! When using Jetpack in Offline mode, some features that rely on external connections, like DNS queries, may not function as expected. The warning you’re seeing is likely due to this limitation.

    Since you’re working in a local environment, these warnings can be safely ignored. They won’t affect your local development. However, if you need to test features that require a connection, you might consider setting up an online staging site for a more accurate experience.

    Let me know this helps or if you have any questions!

    Best,
    Alin

    Thread Starter daymobrew

    (@daymobrew)

    I understand that some online features are not going to work in offline mode but the code should handle this gracefully, without throwing warnings.

    The code in question is in the get_nameserver_dns_records() function. At the top of it there’s a check for the dns_get_record() function. There should then be a check for offline mode and return an empty array if true. This would fix both warnings.

    • This reply was modified 2 months, 3 weeks ago by daymobrew.
    Plugin Support Chatoxz (a11n)

    (@chatoxz)

    Hi there,

    Thank you for your feedback on handling warnings in Offline mode. Your suggestion to check for Offline mode and return an empty array is valid and could improve the code’s robustness.

    If you want to request a change you can do it on the Jetpack repository: https://github.com/Automattic/jetpack/issues/new?template=feature_request.md

    If you have any more questions or need further assistance, please reply to this thread.

    Warm regards,

    Thread Starter daymobrew

    (@daymobrew)

    A quick fix is to add ‘@’ before the dns_get_record() call i.e.

    $dns_records = @dns_get_record( $domain, DNS_NS ); // Fetches the DNS records of type NS (Name Server)

    as this will supress the PHP warning.

    I will submit this suggestion to the Jetpack repository.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    I will submit this suggestion to the Jetpack repository.

    Thanks for the report, and thank you for submitting a patch! I just replied to your suggestion on GitHub.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.