hey everyone,
I am facing same issue with WooCommerce WC_Meta_object class. Unless I force encode/decode the result being passed, it returns as incomplete class error:
public function save_cache( $result, \WP_REST_Server $server, \WP_REST_Request $request ) {
// Only Avoid cache if not 200.
if ( ! empty( $result ) && is_array( $result ) && isset( $result['data']['status'] ) && 200 !== (int) $result['data']['status'] ) {
return $result;
}
// Do not cache if empty result set.
if ( empty( $result ) ) {
return $result;
}
// force evaluate the result
$result = json_decode(wp_json_encode($result));
$data = array(
'data' => $result,
'headers' => $this->response_headers,
);
\WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->set_cache( $this->cache_key, $data, 'endpoint', $this->request_uri, '', $this->request_headers );
return $result;
}
The issue seems to be that WC_meta_object class i not available to wp-rest-cache plugin, Do you have a better idea on how to fix?