wp-papi / papi

:rocket: WordPress Page Type API with custom fields
https://wp-papi.github.io
MIT License
263 stars 32 forks source link

[3.2.0-beta1] PHP Notices in REST integration #233

Closed entr closed 7 years ago

entr commented 7 years ago

REST troubles in the new beta.

Notice:  Undefined variable: ID in /home/zlatev/public_html/rest/wp/wp-content/plugins/papi/src/rest-api/class-papi-rest-api-post.php on line 93
Stack trace:
  1. {main}() /home/zlatev/.composer/vendor/cpriego/valet-linux/server.php:0
  2. require() /home/zlatev/.composer/vendor/cpriego/valet-linux/server.php:197
  3. require() /home/zlatev/public_html/rest/index.php:17
  4. wp() /home/zlatev/public_html/rest/wp/wp-blog-header.php:16
  5. WP->main() /home/zlatev/public_html/rest/wp/wp-includes/functions.php:955
  6. WP->parse_request() /home/zlatev/public_html/rest/wp/wp-includes/class-wp.php:733
  7. do_action_ref_array() /home/zlatev/public_html/rest/wp/wp-includes/class-wp.php:386
  8. WP_Hook->do_action() /home/zlatev/public_html/rest/wp/wp-includes/plugin.php:515
  9. WP_Hook->apply_filters() /home/zlatev/public_html/rest/wp/wp-includes/class-wp-hook.php:323
 10. rest_api_loaded() /home/zlatev/public_html/rest/wp/wp-includes/class-wp-hook.php:298
 11. WP_REST_Server->serve_request() /home/zlatev/public_html/rest/wp/wp-includes/rest-api.php:271
 12. WP_REST_Server->dispatch() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/class-wp-rest-server.php:323
 13. WP_REST_Posts_Controller->get_item() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/class-wp-rest-server.php:927
 14. WP_REST_Posts_Controller->prepare_item_for_response() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:469
 15. apply_filters() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1574
 16. WP_Hook->apply_filters() /home/zlatev/public_html/rest/wp/wp-includes/plugin.php:203
 17. Papi_REST_API_Post->prepare_response() /home/zlatev/public_html/rest/wp/wp-includes/class-wp-hook.php:300
 18. Papi_REST_API_Post->prepare_property_value() /home/zlatev/public_html/rest/wp/wp-content/plugins/papi/src/rest-api/class-papi-rest-api-post.php:74
Notice:  Undefined variable: id in /home/zlatev/public_html/rest/wp/wp-content/plugins/papi/src/rest-api/class-papi-rest-api-post.php on line 93
Stack trace:
  1. {main}() /home/zlatev/.composer/vendor/cpriego/valet-linux/server.php:0
  2. require() /home/zlatev/.composer/vendor/cpriego/valet-linux/server.php:197
  3. require() /home/zlatev/public_html/rest/index.php:17
  4. wp() /home/zlatev/public_html/rest/wp/wp-blog-header.php:16
  5. WP->main() /home/zlatev/public_html/rest/wp/wp-includes/functions.php:955
  6. WP->parse_request() /home/zlatev/public_html/rest/wp/wp-includes/class-wp.php:733
  7. do_action_ref_array() /home/zlatev/public_html/rest/wp/wp-includes/class-wp.php:386
  8. WP_Hook->do_action() /home/zlatev/public_html/rest/wp/wp-includes/plugin.php:515
  9. WP_Hook->apply_filters() /home/zlatev/public_html/rest/wp/wp-includes/class-wp-hook.php:323
 10. rest_api_loaded() /home/zlatev/public_html/rest/wp/wp-includes/class-wp-hook.php:298
 11. WP_REST_Server->serve_request() /home/zlatev/public_html/rest/wp/wp-includes/rest-api.php:271
 12. WP_REST_Server->dispatch() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/class-wp-rest-server.php:323
 13. WP_REST_Posts_Controller->get_item() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/class-wp-rest-server.php:927
 14. WP_REST_Posts_Controller->prepare_item_for_response() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:469
 15. apply_filters() /home/zlatev/public_html/rest/wp/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1574
 16. WP_Hook->apply_filters() /home/zlatev/public_html/rest/wp/wp-includes/plugin.php:203
 17. Papi_REST_API_Post->prepare_response() /home/zlatev/public_html/rest/wp/wp-includes/class-wp-hook.php:300
 18. Papi_REST_API_Post->prepare_property_value() /home/zlatev/public_html/rest/wp/wp-content/plugins/papi/src/rest-api/class-papi-rest-api-post.php:74

This is happening for the /v2/pages/ route. In the first notice ID is undefined, but id is there. Also requested page is of standard type (no special papi type applied), but the moment I created a new page type class all my existing pages were shown as of this new type in the edit.php?post_type=page table. Let me know if more info is needed.

frozzare commented 7 years ago

This is fixed in master branch, closing.

entr commented 7 years ago

Good, thanks.