Opened 21 months ago
Last modified 5 months ago
#57973 new defect (bug)
Can not delete custom template when name contains non-Latin characters
Reported by: | funway | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.1.1 |
Component: | REST API | Keywords: | has-testing-info has-screenshots |
Focuses: | rest-api | Cc: |
Description
I can create a custom template whose name contains non-Latin characters.
But when I delete this template.
It failed without any message in the front-end.
I can only find out the error message in the developer tools.
The ajax post request '/wp/v2/templates/theme_nametemplate_name' returns 404.
I think the problem is caused by the two slashes before none-Latin template_name.
To reproduce:
- create a new template with non-Latin characters in post editor.
- save the template, re-enter a post editor.
- choose the template, and click 'edit template'.
- open your browser's developer tools with the network tab.
- click 'delete template', then you will see the 404 error in your developer tools.
Attachments (2)
Change History (9)
#2
@
21 months ago
Testing on WP 6.2-RC4, the non-Latin named templates are being deleted perfectly.
#3
@
6 months ago
- Keywords close added; needs-testing removed
Reproduction Report
Environment
- WordPress: 6.6-beta3-58440-src
- PHP: 7.3.33
- Server: Apache/2.4.57 (Unix) PHP/7.3.33
- Database: mysqli (Server: 5.7.43 / Client: mysqlnd 5.0.12-dev)
- Browser: Safari 17.5 (macOS)
- Theme: Twenty Twenty-Four 1.1
- MU-Plugins: None activated
Actual Results
- ❌ Cannot reproduce the bug.
Supplemental Artifacts
#4
@
6 months ago
Thank you for submitting the ticket, @funway.
As both test reports indicate the bug cannot be reproduced, could this Trac ticket be closed?
#5
@
5 months ago
- Focuses javascript removed
- Keywords close removed
I am unable to reproduce this issue with templates created in WP 6.4 and up. Since 6.4, non-Latin characters are removed from saved template slugs. E.g. a template named กรุงเทพฯ
is now by default saved as wp-custom-template
.
However, for a template with non-Latin characters created in <= 6.3, it cannot be deleted in 6.5.5. In 6.3, a template named กรุงเทพฯ
is saved with a slug of wp-custom-template-กรุงเทพฯ
, which in newer WP versions cannot be modified or deleted.
Because saving templates with non-Latin characters was added in 6.2, I feel this report is still valid, as there is somewhat of a backward-compatibility break with the change in 6.4. It seems endpoint support for non-Latin characters or some type of migration for now "invalid" template slugs should be considered. As of today, one cannot "clean up" these older templates directly in the UI.
I've removed close
for additional test and upgrade input and discussion around the backward-compat impact.
Reproduction Report
tl;dr Can repro in upgrade from <6.4, but not for templates created in 6.4+.
Environment
WordPress Playground
- PHP 8.0, 6.2 thru 6.6-RC1, Twenty-Twenty Two
Local (for post-upgrade test)
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 14.5
- Browser: Safari 17.5
- Server: nginx/1.27.0
- PHP: 8.2.20
- SQLite: 3.43.2
- WordPress: 6.3 and 6.5.5
- Theme: twentytwentytwo
Actual Results
- ❌ In 6.4+, a template created with non-Latin characters in name is deleted successfully. No 404 responses observed.
- ✅ In <= 6.3, a template created with non-Latin characters in name cannot be deleted after upgrading to 6.4+. Attempts to modify or delete the template result in a 404.
#6
@
5 months ago
Thank you for the test report, @ironprogrammer.
I've tested this issue again.
I created custom templates in WordPress 6.2 and then attempted to delete them after upgrading to WordPress 6.3 and 6.5.5 using WP-CLI
. In both cases, I successfully deleted the templates without encountering any issues.
Since I could not reproduce the bug in my environment, I will leave this for someone else to investigate and address.
Hi @funway, welcome to Trac and thanks for opening this ticket and for the steps to reproduce the issue!
Saving templates with non-Latin characters was handled in #57329. It appears that support for deleting these templates should be added if this issue can be reproduced by other contributors.
For now, I'll mark this with
needs-testing
so that other contributors can verify whether the issue can be reproduced, and we can move forward from there.