-
Notifications
You must be signed in to change notification settings - Fork 138
Description
When pretty permalinks aren't enabled, Optimization Detective sends the URL metrics data to the /index.php?rest_route=%2Foptimization-detective%2Fv1%2Furl-metrics%3Astore&_wpnonce=d6ef56f704. This ends up causing the request to fail with:
{
"code": "rest_invalid_param",
"message": "Failed to validate URL metric: rest_route is not a valid property of Object.",
"data": {
"status": 400
}
}This is because rest_route is returned, unexpectedly, as one of the params when calling $request->get_params():
performance/plugins/optimization-detective/storage/rest-api.php
Lines 131 to 136 in ddf297d
| $data = $request->get_params(); | |
| // Remove params which are only used for the REST API request and which are not part of a URL Metric. | |
| unset( | |
| $data['slug'], | |
| $data['nonce'] | |
| ); |
The quick fix would be to unset( $data['rest_route'] ), but it would be better if the params we obtain are exclusively from the JSON body.
This code is also being touched in #1373 where the issue is also occurring.
Granted, likely only a miniscule number of sites don't have pretty permalinks enabled, so this isn't a critical issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status