Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern API: Search requests ignore other API parameters #547

Open
ryelle opened this issue Jan 9, 2023 · 2 comments · May be fixed by #548
Open

Pattern API: Search requests ignore other API parameters #547

ryelle opened this issue Jan 9, 2023 · 2 comments · May be fixed by #548
Labels
[Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint Help Wanted Extra attention is needed [Type] Bug Something isn't working

Comments

@ryelle
Copy link
Contributor

ryelle commented Jan 9, 2023

See #540 (comment)

I'm testing the GB PR and it seems can fetch patterns with more blocks, if we also provide the search param, ex:

https://api.wordpress.org/patterns/1.0/?search=image&allowed_blocks[]=core/heading&allowed_blocks[]=core/gallery

Any insights about this?

Probably due to using ElasticSearch for search results.

Sync the wpop_contains_block_types meta and use it for a filter like 29f7b31.

@ryelle ryelle added [Type] Bug Something isn't working [Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint labels Jan 9, 2023
@ryelle ryelle self-assigned this Jan 9, 2023
ryelle added a commit that referenced this issue Jan 9, 2023
This will let us query on the block types when `allowed_blocks` filter is used in the API.

See #547
ryelle added a commit that referenced this issue Jan 9, 2023
If the `allowed_blocks` meta filter is set, we should also pass that through to the ElasticSearch filters.

See #540. Fixes #547.
@ryelle ryelle linked a pull request Jan 9, 2023 that will close this issue
@ryelle
Copy link
Contributor Author

ryelle commented Jan 23, 2023

I think this issue will also happen if the author_name is passed to the API (see #549).

@ryelle ryelle removed their assignment Jan 23, 2023
@ryelle ryelle changed the title Pattern API: Search parameter seems to override the allowed_blocks filter Pattern API: Search requests ignore other API parameters Jan 24, 2023
@ryelle
Copy link
Contributor Author

ryelle commented Jan 24, 2023

It was noted in #57501-core that the offset, order, and orderby params are not applied to search results in core API requests.

❌ Make sure search still works (search):

/wp-json/wp/v2/pattern-directory/patterns/?search=plants
🟢 search works alone, and along with the per_page and page parameters.
🔴 search is not affected by the offset, orderby, or order parameters.

This is an issue with the wporg API itself— you can test with https://api.wordpress.org/patterns/1.0/?search=form&offset=2. The results don't change despite the offset change.

@ryelle ryelle added the Help Wanted Extra attention is needed label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Pattern Directory API The pattern API on WordPress.org, and/or the CPT endpoint Help Wanted Extra attention is needed [Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant