• 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 672

    This 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;
                }
            }
    
    • This topic was modified 9 years, 4 months ago by eligence.
    • This topic was modified 9 years, 4 months ago by eligence.
    • This topic was modified 9 years, 4 months ago by eligence.
Viewing 1 replies (of 1 total)
  • Thread Starter eligence

    (@eligence)

    Update: the triggering error is either:

    cURL error 6: name lookup timed out

    or

    cURL error 35: SSL connect error

Viewing 1 replies (of 1 total)

The topic ‘PHP Fatal error breaking site’ is closed to new replies.