Skip to content

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!

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