-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix post-format
serialization due to invalid REST API response for id
prop
#31380
Comments
post-format
serializationpost-format
serialization due to invalid REST API response for id
prop
This is an intentional design decision. Post formats do not have an id as part of their public API. Everything is identified by their slug. |
@TimothyBJacobs Thanks for advising on this. I'm going to add some more context from our Slack convo:
|
@getdave With the focus on the Navigation block in WP, returning to this to see if there might be any potential to get something moving soon on this issue, or not. Thanks! |
@kathrynwp Thanks for flagging. Probably a relatively low priority item but nonetheless one we should be able to solve. @TimothyBJacobs I think you've said before that you wouldn't be happy exposing the taxonomy's term ID as that's an implementation detail. If that's still the case then we could look at manually providing a hardcoded ID for each Post Format on the client side. It seems like there's a limited set of formats so this could just be a map of Post Format slug to hardcoded ID. However it's non-optimal. |
Can the client be updated to accept a |
The next step here is actually to work out whether this issue is currently manifesting itself in the Navigation block. If it's not then I think we have more pressing problems to deal with that will have a bigger impact on user experience. Not saying it's not important but perhaps a lower priority. I'll make a note to see if I can replicate the problem. If not then I say we archive this Issue and it can be picked up in the future if/when this becomes a problem. |
Closing the issue since the editor is no longer maintained and has been removed from the project. |
As part of #31004 it was discovered that adding a
Post Format
type link variation in the new Navigation editor screen (only) does not work - the item is saved with the wrong type or the request does not succeed.Please note: the error is only manifesting when you create the Post Format
core/navigation-link
block'spost_type
variation in the Navigation Editor screen.The reason for this is that when the block is serialized into a nav_menu_item for storage its
object_id
is not set to an integer. Rather instead it is set to the slug which represents the Post Format (eg:video
,quote
,standard
....etc)This is incorrect. It should be an integer ID representing the ID of the post-format.
Where does the incorrect ID come from?
This error is actually coming from the REST API request to
/v2/search
itself which is fired when the user performs a search in the link UI to select a Post Format.Try this in your browser:
http://localhost:8888/index.php?rest_route=%2Fwp%2Fv2%2Fsearch&search=&per_page=3&type=post-format&_locale=user
If you have Post Formats created (see below for how to do this) you will see something akin to the following in the response:
This
id
prop is then used throughout the block UI as an attribute and therefore when the Navigation Editor tries to serialize the blocks to menu items in order to be saved theobject_id
is set to the incorrectid
prop resulting in the error.Proposed solution
This looks like a REST API issue. However, it may be completely legitimate for the endpoint to return this data type for the
ID
property as the schema allows forinteger or string
.Options:
object_id
prop for the post formats only. We would then have to map this property toid
before using it in the editor.As a first step I would like to discuss with @TimothyBJacobs and the REST API team to get their opinion.
Aside: creating some Post Formats
The best way to do this is:
Post Format
.Originally posted by @gwwar in #31004 (comment)
The text was updated successfully, but these errors were encountered: