Plugin stops all articles from loading when url shortener is down
-
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
Viewing 3 replies - 1 through 3 (of 3 total)
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.