Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#53305 closed defect (bug) (fixed)

REST API: Duplicate widget types in /wp/v2/widget-types

Reported by: noisysocks's profile noisysocks Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.8 Priority: normal
Severity: normal Version: 5.8
Component: REST API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description (last modified by noisysocks)

The /wp/v2/widget-types endpoint is returning duplicate widget types which causes the issue described in https://github.com/WordPress/gutenberg/issues/32019.

Using https://httpie.io:

$ http -a admin:password GET http://wp-git-build.test/wp-json/wp/v2/widget-types | jq '.[].id'
"pages"
"calendar"
"archives"
"media_audio"
"media_image"
"media_gallery"
"media_video"
"meta"
"search"
"search"
"text"
"categories"
"recent-posts"
"recent-comments"
"rss"
"tag_cloud"
"nav_menu"
"custom_html"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"
"block"

Change History (5)

#1 @noisysocks
3 years ago

  • Description modified (diff)

This ticket was mentioned in PR #1317 on WordPress/wordpress-develop by noisysocks.


3 years ago
#2

  • Keywords has-patch has-unit-tests added

Modifies the /wp/v2/widget-types endpoint to de-duplicate widget types by their id. Duplicates appear because WP_Widget::_register will add one entry to $wp_registered_widgets per widget instance.

Trac ticket: https://core.trac.wordpress.org/ticket/53305

#3 @SergeyBiryukov
3 years ago

#53302 was marked as a duplicate.

#4 @spacedmonkey
3 years ago

@noisysocks
I also had a ticket for this at #53302

Also related #53303

Now that the widgets array has key, we could ksort to make sure widget types are in an alphabetical order.

#5 @TimothyBlynJacobs
3 years ago

  • Owner set to TimothyBlynJacobs
  • Resolution set to fixed
  • Status changed from new to closed

In 51049:

REST API: Remove duplicates in the widget types endpoint.

Props noisysocks, spacedmonkey, imath, isabel_brison.
Fixes #53305.

Note: See TracTickets for help on using tickets.