PHP Fatal error breaking site
-
PHP Fatal error: Cannot use object of type WP_Error as array in /wp-content/plugins/company-updates-for-linkedin/linkedin-company-updates.php on line 672This error in your plugin was thrown as a result of gracefully handling WP_Errors. It occurs randomly causing our site to break and prevents javascript from loading. We recommend editing lines 658-688 to be:
/** * GETs remote json data * @param string $url url from which to fetch the data * @param string $error_message Text error message * @return array | false */ private function get_remote_json( $url, $error_message ) { try { // make the GET request $response = wp_remote_get( $url ); if ($response instanceof \WP_Error) { $this->notification( $response->get_error_message() ); return false; } else { $json = json_decode($response['body'], 1); // check for errors if (isset($json['error'])) { throw new Error($json['error_description']); } return $json; } // handle errors } catch ( Exception $ex ) { $this->notification( $ex->getMessage() ); return false; } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘PHP Fatal error breaking site’ is closed to new replies.