简体   繁体   中英

Fatal Wordpress Error: Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in

I just started receiving this error. No idea how this happened as I have updates turned off. Code is below:

// Convert json to php array.
$files_data = json_decode($request['body']);
if($files_data === null)
    return ;

Looks like you are getting an instance of WP_Error in $request['body']. You can patch your code like so...

<?php

$files_data = !is_wp_error($request['body']) ? json_decode($request['body']) : null;
if($files_data === null)
    return ;

But you should really look in to the WP_Error error and fix that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM