This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Not passing args to $wpdb->prepare
causes PHP notice to show which breaks API requests
#5159
Labels
focus: rest api
Work impacting REST api routes.
type: bug
The issue/PR concerns a confirmed bug.
type: good first issue
The issue is a good candidate for the first community contribution/for a newcomer to the team.
Describe the bug
When you have error reporting turned on, calls to
$wpdb->prepare
causes notices to print which breaks API requests, for example:https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/a4602f8be133bcc6072cd691693f2ea0fffca0d1/src/StoreApi/Schemas/ProductCategorySchema.php#L115
is missing 2nd...nth arguments, which causes this error:
PHP Notice: Undefined offset: 0 in /var/www/html/wp-includes/wp-db.php on line 1323
We should check usages of this function and make it so we pass additional args to it.
To reproduce
Steps to reproduce the behavior:
PHP Notice: Undefined offset: 0 in /var/www/html/wp-includes/wp-db.php on line 1323
printed in the API response.Expected behavior
No notices should be printed in the API Response.
Screenshots
Environment
Happens in both PHP 8.0 and 7.4
WordPress (please complete the following information):
Desktop (please complete the following information):
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: