disqus / disqus-wordpress-plugin

WordPress plugin for Disqus (Latest version)
https://disqus.com/
34 stars 25 forks source link

Exception when treating error response from Disqus API as an array #29

Closed ryanvalentin closed 6 years ago

ryanvalentin commented 6 years ago

Using the WordPress functions wp_remote_get and wp_remote_post can return either an array (success) or an instance of WP_Error if there was an exception. Currently we're treating either case as an array: https://github.com/disqus/disqus-wordpress-plugin/blob/7d5531e4f3e1746b2291f8e2664430433e8dbf17/disqus/includes/class-disqus-api-service.php#L82

When the Disqus API throws an error, a new exception gets created trying to access the WP_Error object as an array.

We need to detect when an error is thrown and return the appropriate response from there.