airesvsg / acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API
https://wordpress.org/plugins/acf-to-rest-api/
1.33k stars 110 forks source link

FIX: Fix Uncaught Error: Call to undefined method WP_Error::get_data() #357

Closed gtsvetanov closed 3 years ago

gtsvetanov commented 3 years ago

Hello today I've found this issue when WP_REST_Posts_Controller->get_items() returned an WP_Error object but ACF_To_REST_API_Controller->get_items() didn't handle it. This can be reproduced when you exceed total posts in WP_REST_Posts_Controller line 351 for WP version 5.5.1. I think this issue is reproducible on older versions too.

So I've made a quick fix to handle WP_Error object to prevent breaking of the API.

Best regards, Georgi!