jaredatch / EA-Share-Count

A lean plugin that leverages SharedCount.com API to quickly retrieve, cache, and display various social sharing counts.
84 stars 13 forks source link

PHP Fatal Error due to improperly accessing body in HTTP request #68

Closed emmtre closed 7 years ago

emmtre commented 7 years ago

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
jaredatch commented 7 years ago

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.

emmtre commented 7 years ago

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