Fatal error: Cannot use object of type WP_Error as array
-
Error occures when I publish a new post. Everything works, but the message shows up right after saving. This may confuse some users.
Message:
Fatal error: Cannot use object of type WP_Error as array in /www/htdocs/.../wp-content/plugins/search-everything/search-everything.php on line 927WordPress Version 4.7.10
Plugin Version 8.1.9
-
I can only report the same thing with WordPress Version 4.2.19. It used to work reliably before March or April. Any insight into solutions?
Thanks!
I am also facing the same issue from yesterday.
How to fix it?
Please reply as soon as possible.I’m getting this as well.
Wordpress 4.9.5
Search Everything 8.1.9An line from my Apache error log:
https://pastebin.com/UjavHFFYHere is the code that fails. It is failing on a call to Zemanta because the json decode does not work.
function se_post_publish_ping($post_id) { //should happen only on first publish $status = false; if( !empty( $_POST['post_status'] ) && ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) { $permalink = get_permalink($post_id); $zemanta_response = se_api(array( 'method' => 'zemanta.post_published_ping', 'current_url' => $permalink, 'post_url' => $permalink, 'post_rid' => '', 'interface' => 'wordpress-se', 'deployment' => 'search-everything', 'format' => 'json' )); <strong>$response = json_decode($zemanta_response['body']); if (isset($response->status) && !is_wp_error($zemanta_response)) { $status = $response->status; }</strong> } return $status; }You can change it to :
function se_post_publish_ping($post_id) { //should happen only on first publish $status = false; if( !empty( $_POST['post_status'] ) && ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) { $permalink = get_permalink($post_id); $zemanta_response = se_api(array( 'method' => 'zemanta.post_published_ping', 'current_url' => $permalink, 'post_url' => $permalink, 'post_rid' => '', 'interface' => 'wordpress-se', 'deployment' => 'search-everything', 'format' => 'json' )); if (!is_wp_error($zemanta_response)) { $response = json_decode($zemanta_response['body']); if (isset($response->status)) { $status = $response->status; } } } return $status; }@andronidko
Thank you! Your fix did the trick for me.This worked for me as well.
Thanks, Karla! Worked for me too. Anyone know if the developer knows about this yet?
-
This reply was modified 7 years, 11 months ago by
nosillacast.
Thank you, it worked.
Thanks for the fix. Will it be integrated in the next release of the plugin?
This simple conditional wrapper worked for me too. Many thanks!
This plugin has clearly been abandoned. While it was interesting to run this fix, I have moved on to relevanssi (https://ww.wp.xz.cn/plugins/relevanssi/) which is in active development. Running out of date plugins is really dangerous. I suggest everyone move along!
I’m also having this error but on the IMDB API app:
”
public function get($id = false,$type = ‘json’)
{
$param = array(
‘body’=>array(
‘key’=>$this->api_key,
‘id’=>$id,
‘type’=>$type
)
);
$response = wp_remote_post($this->url,$param);
if(@$response[‘response’][‘code’] == 200){
return wp_remote_retrieve_body($response);
}
else {
return $this->result;
}
}
”
Is there a simple code change I can make for it so that it will behave?
Any help greatly appreciated!Thank you so much @andronidko
You made my day brother..!!!Plugin developers must resolve this issue earlier. This issue still exists.
-
This reply was modified 7 years, 4 months ago by
Chinmay Rajyaguru.
This is now an abondoned plugin with as it was last updated 2 years ago.
fyi This is the $zemanta_response.
WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => cURL error 6: Could not resolve host: api.zemanta.com ) ) [error_data] => Array ( ) ) -
This reply was modified 7 years, 11 months ago by
The topic ‘Fatal error: Cannot use object of type WP_Error as array’ is closed to new replies.