Skip to content

Conversation

andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Oct 6, 2025

This PR updates the post link within the REST API media attachment response to use the https://api.w.org/ prefix, as post isn't a valid IANA link relation: https://www.iana.org/assignments/link-relations/link-relations.xhtml

Kudos @TimothyBJacobs for catching this.

Testing instructions

These are basically the same testing instructions as in #10027:

If you'd like to test this from within the block editor:

  1. Open up the media library and upload an image.
  2. From the list view within the media library, click Attach under the Uploaded To column and attach the media items to a post
  3. Make a note of the id of your images (i.e. grab it from the url)
  4. Open the block editor, and try running the following from your browser console (note you might have to run these commands twice as the first call will return undefined as the request hasn't been resolved yet):
// Replace 27 with the id of an image that is attached to a post — you should see `wp:attached-to` in the list of `_links`
wp.data.select( 'core' ).getEntityRecord( 'postType', 'attachment', 27 );
// Again, replace 27 with the id of an image that is attached to a post — in this call, you should see the `wp:attached-to` under `_embedded` in the response
wp.data.select( 'core' ).getEntityRecord( 'postType', 'attachment', 27, { _embed: 'wp:attached-to' } );

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


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

github-actions bot commented Oct 6, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props andrewserong, mukesh27, ramonopoly.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented Oct 6, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.


if ( ! empty( $post ) ) {
$links['post'] = array(
$links['https://api.w.org/post'] = array(
Copy link
Member

Choose a reason for hiding this comment

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

Does it break the BC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it break the BC?

No, there's no breaking change here as this hasn't made it into a release yet.

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

Good catch!

I forgot about this URI relation too.

@andrewserong
Copy link
Contributor Author

I've just updated to rename to https://api.w.org/attached-to to try giving this a clearer, descriptive link relation.

@ramonjd
Copy link
Member

ramonjd commented Oct 6, 2025

giving this a clearer, descriptive link relation.

Thanks @andrewserong

If it's good with @TimothyBJacobs then it still LGTM

@andrewserong
Copy link
Contributor Author

Thanks for re-reviewing! I'll see if there's any feedback overnight and hopefully commit this tomorrow.

Copy link

github-actions bot commented Oct 8, 2025

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 60916
GitHub commit: 692a5b1

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Oct 8, 2025
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.

3 participants