Repository navigation
Media: Return 0 from the edit root lookup when there is no edit root - #84096
Conversation
Backports the review changes from WordPress/wordpress-develop#13303: the lookup returns 0 for uploads and for attachments recorded as their own edit root, and multi-assertion tests carry failure messages.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the ⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. sort patterns (Site Editor v2) in
|
andrewserong
left a comment
There was a problem hiding this comment.
Nice idea moving the logic to get_edit_root_attachment_id rather than at the field and link level, this feels tidier 👍
Smoke-tested that this is still working well for a non cropped image (edit root is 0) and a first crop and a crop of a crop both return the edit root of the original attachment.
LGTM! 🚀
What?
Follow-up to #81803. Backports the changes from the review of WordPress/wordpress-develop#13303 (fecd8bd, 6c95f24). Props to @peterwilsoncc for the suggestions.
Why?
gutenberg_get_edit_root_attachment_id()should match core'swp_get_edit_root_attachment_id(), which now returns0when there is no edit root instead of the ID passed in.How?
0for uploads and for attachments recorded as their own edit root./edithook falls back to the source attachment's ID when it has no edit root of its own.wp:edit-rootlink check for0directly.No change to the REST
edit_rootvalue: it was already0when there is no edit root.Testing Instructions
await wp.apiFetch( { path: '/wp/v2/media/<new id>?context=edit' } ).edit_rootis the original upload's ID and_linkshaswp:edit-root.edit_rootis still the original upload's ID.edit_rootis0and there is nowp:edit-rootlink.Cropped image:
Original (root) image: