#57914 closed defect (bug) (duplicate)
CPT created during the same second can be retrieved by the API in the wrong order
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.1.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | rest-api | Cc: |
Description
This bug was uncovered while writing an e2e test for the navigation block (https://github.com/WordPress/gutenberg/pull/48132#discussion_r1130847269).
When the navigation block retrieves the latest navigation from the database, the API will return the oldest one if they were created during the same second (https://github.com/WordPress/gutenberg/blob/621c2556e843c7c2c0210e13115d29026f6854c4/packages/block-library/src/navigation/use-navigation-menu.js#L98)
This will only happen when the CPT are created programmatically. To reproduce this, run the e2e test from https://github.com/WordPress/gutenberg/pull/48132 ('default to my most recently created menu') without the timeout between the creation of the two menus. Without said timeout, the API returned the oldest one instead of the newest one.
Thanx for the ticket.
I suspect this is the same (or at least a related) issue as #44349.