Handle expired or missing tokens for orders autosuggest #3308
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Description of the Change
Adds handling for missing or expired tokens. Now if an search fails a new token will be fetched and the search will be reattempted. This will handle situations where a token has expired. Refreshing a token will only be attempted once.
Additionally I've included a few fixes for the suggestion dropdown:
Closes #3296
How to test the Change
From #3175:
( new Orders() )->setup();
to thesetup()
method of the WooCommerce feature class.New:
wp-json/elasticpress/v1/token
should be sent and should return a token.wp_usermeta
, findep_token
for your user and manipulate it so that it's invalid.wp-json/elasticpress/v1/token
should be sent and should return the manipulated token.wp-json/elasticpress/v1/token
should be sent and should return a new token. Another API request to ElasticPress.io should follow and should succeed. Suggestions should now be offered in a listbox below the search form.Changelog Entry
See #3175
Credits
Props @JakePT
Checklist: