• I have faced this often when my internet connection is not connected and I am working on localhost.
    Today it happened when bitly was not reachable for a while. That was about 3 hours back.
    PHP Fatal error: Cannot use object of type WP_Error as array in public_html/wp-content/plugins/url-shortener/components/jz_shortener/lib/jzsc.shared.php on line 235

    Checking that line of code, it reads

    if($result['body']){
                        $data = $result['body'];
                    }

    That throws is an issue when there is an error in actually fetching the data. wp_http instead gives wp_error.
    It would be good to check if the key body exists in the array as follows:

    if (array_key_exists('body',$result) {
        $data = $result['body'];
    }

    Here’s the WP_Error thrown by WP_Http when bitly isn’t reachable

    object(WP_Error)[16]
      public 'errors' =>
        array (size=1)
          'http_request_failed' =>
            array (size=1)
              0 => string 'Could not resolve host: api.bit.ly; Unknown error' (length=49)
      public 'error_data' =>
        array (size=0)
          empty

    https://www.ads-software.com/extend/plugins/url-shortener/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you find a solution to this? I just got the same error. It takes down my whole site instead of just breaking the plugin. This is not acceptable. Is there a workaround? Temporarily I had to pull the entire plugin.

    By the way, actually dragging the plugin out of the Plugins folder didn’t work in and of itself; I had to login, go to plugins, see the “The plugin url-shortener/url-shortener.php has been deactivated due to an error: Plugin file does not exist.” message, and only then did my site come back up.

    In my case, I pulled the plugin, visited my plugins page, and then pulled the plugin back in and chose a different service (I was on TinyURL and switched to Goo.gl). So far, my short URLs have not been regenerated (the plugin should do that automatically, right?) but the old TinyURL shortlinks still work. The main thing is that the fatal error has disappeared.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin stops all articles from loading when url shortener is down’ is closed to new replies.