Make WordPress Core

Opened 5 weeks ago

Closed 3 weeks ago

#62776 closed defect (bug) (reported-upstream)

Non-latin post type rewrite slugs break post editor since 6.7

Reported by: terraling's profile terraling Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.7
Component: Editor Keywords: dev-feedback
Focuses: Cc:

Description

If you register a CPT with a rewrite slug that uses non-latin characters then when you click a back-end link to edit such a post the editor fails to load and displays a message "You attempted to edit an item that doesn't exist. Perhaps it was deleted?".

Does not happen in WordPress 6.6.2, happens in WordPress 6.7+

Only occurs with the Block Editor, does not occur with the Classic Editor.

The message comes from the Editor function in wp-includes/js/dist/editor.js (the code is too opaque for me to spot what exactly is the cause).

To reproduce, register a CPT that uses non-latin characters in the rewrite slug (in my example I'm using Ukranian, but the same applies with languages like Chinese or Hebrew), e.g.:

<?php
function wporg_custom_post_type()
{
    $recipe_labels = array(
        'name' => __('Recipes', 'asif'),
        'singular_name' => __('Recipe', 'asif'),
        'add_new' => __('New Recipe', 'asif'),
        'add_new_item' => __('Add New Recipe', 'asif'),
        'edit_item' => __('Edit Recipe', 'asif'),
        'new_item' => __('New Recipe', 'asif'),
        'view_item' => __('View Recipe', 'asif'),
        'search_items' => __('Search Recipes', 'asif'),
        'not_found' => __('No Recipes Found', 'asif'),
        'not_found_in_trash' => __('No Recipes found in Trash', 'asif'),
    );

    $recipe_args = array(
        'labels' => $recipe_labels,
        'public' => true,
        'rewrite' => array('slug' => 'рецепт'), // non-Latin slug
        'show_in_rest' => true,
    );

    register_post_type('recipe', $recipe_args);
}
add_action('init', 'wporg_custom_post_type');

Publish a post of that post type, go to the list of posts (e.g. Dashboard > Recipes) then click the edit link to edit the post.

(Note, I had already created a test post before upgrading to WP 6.7; I don't know if you can publish a post with a non-Latin rewrite slug if you are already on WP 6.7, but if not you could temporarily use Classic Editor.)

Change History (5)

#1 @ketanniruke
5 weeks ago

You may update rewrite code with -
'rewrite' => array(
'slug' => urlencode('мой-тип'),
),

Last edited 5 weeks ago by ketanniruke (previous) (diff)

#2 @poena
5 weeks ago

  • Keywords dev-feedback added
  • Severity changed from major to normal

Hi

I can reproduce this but only if I start on 6.6.2 and upgrade to 6.7.1.
I am not sure how to troubleshoot it further.
If I use one of my fresh 6.7.1 installs, I can not reproduce it.

@youknowriad may it be related to https://github.com/WordPress/gutenberg/pull/62274 ?

This ticket was mentioned in Slack in #core-editor by poena. View the logs.


3 weeks ago

#4 @wildworks
3 weeks ago

I have identified the problem in the Gutenberg PR. This issue should be fixed in the Gutenberg project.

Gutenberg Issue: https://github.com/WordPress/gutenberg/issues/68793

#5 @poena
3 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.