jaredatch/EA-Share-Count

PHP Fatal Error due to improperly accessing body in HTTP request

Closed this issue · 2 comments

Have you seen this PHP errors before? Multisite with PHP 7.0.10 and WP 4.6.1. I noticed a few today in the log but I haven't seen any before.

PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /public_html/wp-content/plugins/ea-share-count/includes/class-core.php:427
Stack trace:
#0 /public_html/wp-content/plugins/ea-share-count/includes/class-core.php(473): EA_Share_Count_Core->query_api('http://...')
#1 /public_html/wp-includes/plugin.php(524): EA_Share_Count_Core->update_share_counts('')
#2 /public_html/wp-includes/load.php(671): do_action('shutdown')
#3 [internal function]: shutdown_action_hook()
#4 {main}
  thrown in /public_html/wp-content/plugins/ea-share-count/includes/class-core.php on line 427

That's due to the recent HTTP request update in WordPress core.

Instead of calling the content body directly (in an array) we need to leverage wp_remote_retrieve_body

https://codex.wordpress.org/Function_API/wp_remote_retrieve_body

Will fix in the next release.

Ok good to know that the problem is on your radar! :-)