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

Patterns API: Fix the category_slugs format for featured patterns #711

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

ParhamG
Copy link
Contributor

@ParhamG ParhamG commented Oct 1, 2024

This fixes a regression caused via #704 that returns category_slugs as an object instead of an array for patterns that has the featured category.

This is breaking the Patterns tab in the block editor for all WP sites.

The modified array returned by array_diff() can have non-consecutive indexes, causing it to be JSON-encoded as an object rather than array which is the expected format. Applying array_values() to the response fixes it.

  1. View the response for https://api.wordpress.org/patterns/1.0/?page=1&per_page=100&order=desc&orderby=date&locale=en_US&wp-version=6.6.1&pattern-keywords=11
  2. Lookup the pattern with "id": 199
  3. The value for its "category_slugs" attribute must be an array and not an object

This fixes a regression caused via WordPress#704 that returns category_slugs as an object instead of an array
Copy link
Contributor

@ryelle ryelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and explanation!

@ryelle ryelle merged commit a47c46c into WordPress:trunk Oct 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants