Open sjregan opened 3 years ago
Hi @sjregan ,
Thank you for opening the issue! It requires further feedback from the WooCommerce Core team. I am adding the needs developer feedback
label to this issue so that the Core team could take a look.
Please note it may take a few days for them to get to this issue. Thank you for your patience.
Hi @sjregan,
Thanks for reporting this. It does look like the PHP Doc on that filter is incorrect. Unfortunately, for backwards-compatibility reasons, it will be hard for us to update that filter to pass the object instead of the string. I'm going to leave this issue open to track updating the PHP Doc to make it more accurate to its actual behavior.
@jonathansadowski Thanks for looking at it, I understand your point of backwards compatibility.
I would like to point out the issue is not that the PHPDoc is incorrect, its that the parameter type is incorrect because it differs from the same filter in the WP_REST_Posts_Controller
class.
Prerequisites (mark completed items with an [x]):
Describe the bug A clear and concise description of what the bug is.
In WooCommerce v5.4.1 the class-wc-rest-crud-controller.php class calls the “rest_{$this->post_type}_collection_params” filter incorrectly:
The PHPDoc states the $post_type variable is meant to be of type WP_Post_Type, however this call provides the parameter as a string.
When WP calls the same filter it provides a WP_Post_Type object.
Expected behavior The correct parameter type (WP_Post_Type ) should be passed to the function.
Actual behavior The string slug of the post type is passed instead of the object.
Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.) Steps to reproduce the bug:
Screenshots If applicable, add screenshots to help explain your problem.
Isolating the problem (mark completed items with an [x]):
WordPress Environment We use the WooCommerce System Status Report to help us evaluate the issue. Without this report we won't be able to fully evaluate this issue.