Opened 2 months ago
Last modified 40 hours ago
#57957 new defect (bug)
Media title falsely has kebab case when inserted via REST API (e.g. in Block Editor)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.2.3 | Priority: | normal |
Severity: | major | Version: | 6.1.1 |
Component: | REST API | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description (last modified by )
Reproduction I: "Upload New Media" creates media title "My Great Photo"
1) Media > Add New
2) Drag-n-drop "My Great Photo.jpg"
3) Inspecting this in "Edit Media" shows a media title "My Great Photo".
Reproduction II: Insertion via Block Editor (Gutenberg) creates media title "My-Super-Photo"
1) Edit an existing page or create a new page.
2) Set the cursor into an empty block.
3) Drag-n-drop "My Super Photo.jpg" into this block. This automatically creates a media page behind the scenes.
4) Save the page.
5) Inspecting the media title via "Edit Media"
- Actual: The media title is "My-Super-Photo".
- Expected: The media title should be "My Super Photo".
- The media title should be the filename portion (without the suffix) in its purest possible form (UTF-8) and only the slug and filename should then be transformed according settings regarding ascii/whitespace/transliteration/escaping/punycode/etc.
- Achieving the same goal via different means (Upload New Media vs. drag-n-drop in editor) should result in the same outcome. Otherwise this is an inconsistency.
Analysis & Fix
@adamsilverstein already analyzed and fixed this bug in the Gutenberg issue tracker and asked to re-file here in WordPress Core for review & adding to the codebase.
Adam's Analysis
This is actually something that happens on the core side where the logic to set the title is currently different in the REST API vs. the regular media uploader.
Adam's Fix which should be reviewed
I proposed a fix in WordPress/wordpress-develop #3981 that works in my testing. Would be good to have some additional feedback, maybe from the REST API team.
Environment
- First reported on 2021-08-19 in WordPress v5.8 , confirmed/patched in 2023-02 on a WordPress v6.1.1 instance.
Priority
- If the fix is deemed solid and the review process goes quickly without bumps: Is there a chance that the fix can make it into the 6.2 release? If not, no worry, am happy whenever this will get eventually fixed.
References
- Gutenberg: Discussion and investigation details where it was determined to be a Core issue.
Change History (18)
This ticket was mentioned in PR #3981 on WordPress/wordpress-develop by @adamsilverstein.
2 months ago
#3
- Keywords has-patch added
Match the naming behavior for uploaded media in the REST API to the way media is named when uploading in the media library.
Fixes https://github.com/WordPress/gutenberg/issues/34149
Trac ticket: https://core.trac.wordpress.org/ticket/57957
#4
@
2 months ago
- Description modified (diff)
Adding a link to the original bug report from Gutenberg.
@hellofromTonya commented on PR #3981:
2 months ago
#5
Description updated. This PR is now linked to the Trac ticket ✅
@adamsilverstein are there existing unit tests to validate this fix? If no, would you mind adding tests?
#6
@
2 months ago
- Keywords needs-unit-tests added
@adamsilverstein are there existing unit tests to validate this fix? If no, would you mind adding tests?
Good suggestion @hellofromTonya, will do.
I'd also like to get some more REST API component maintainer feedback, maybe @TimothyBlynJacobs or @spacedmonkey can review?
@adamsilverstein commented on PR #3981:
2 months ago
#7
@adamsilverstein are there existing unit tests to validate this fix? If no, would you mind adding tests?
I'll take a look, thanks for the suggestion.
5 weeks ago
#8
Any idea when this will be ready?
And if it is ready, in which WP version will it be included?
Asking to estimate for myself whether my upcoming mass picture placement session can count on this feature already or whether I must use a workaround. Thanks.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
3 weeks ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
3 weeks ago
#11
@
3 weeks ago
- Milestone changed from 6.2.1 to 6.2.2
Since WordPress 6.2.1 Release candidate 1 is planned today, let's move this ticket to 6.2.2 to give it more time to add unit test cases and proper testing.
#13
@
3 weeks ago
@abitofmind for the moment, this patch still needs unit tests.
Anyone is welcome to refresh the patch to add unit test cases, so this ticket could be considered for the next minor or major release.
#14
@
3 weeks ago
My question is: What's the challenge with the unit tests? And what timeline to expect roughly.
Hello and thanks for the detailed ticket!
This is an annoying bug, but since it wasn't introduced in WP 6.2 development cycle and as we're about to release RC3, it's far too late to fix it during this cycle :)
We can of course fix it in 6.3, but we can also consider this for 6.2.1. For the moment, I'm moving it to 6.2.1 for visibility.