Make WordPress Core

Opened 15 months ago

Last modified 13 months ago

#57438 new defect (bug)

Slug is not generated when saving posts as draft

Reported by: rilwis's profile rilwis Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-testing-info 2nd-opinion
Focuses: administration Cc:

Description

When saving posts as draft, the slug is empty. Only when publishing posts, the slug is generated.

Slug should be auto-generated even when saving posts as draft.

Steps to reproduce:

  • Add a new post (in the classic editor or Gutenberg)
  • Enter the post title
  • Save the post as draft
  • Reload the page (if in Gutenberg) and see the slug is empty

Change History (2)

#1 @ironprogrammer
15 months ago

  • Keywords has-testing-info 2nd-opinion added

Reproduction Report

The slug isn't usually saved until a user has intentionally tried to set/modify it, or the post published, as noted. Flagging for core committer input with 2nd-opinion.

Environment

  • Hardware: MacBook Pro Apple M1 Pro
  • OS: macOS 12.6.2
  • Browser: Safari 16.2
  • Server: nginx/1.23.3
  • PHP: 7.4.33
  • WordPress: 6.2-alpha-54642-src (trunk)

Actual Results

  • ✅ In Quick Edit, the slug value is empty.
  • ✅ In the block editor's Post > URL, the permalink displays a placeholder slug, but it is not saved to the post.
  • ✅ In the Classic Editor, the permalink displays a placeholder slug, but it is not saved to the post.
  • ✅ Created via WP-CLI, the slug value is empty.

Workaround

  • Set the slug through Quick Edit, by interacting with the Permalink value in the block editor (such as clicking inside the text field), or by modifying the default slug in the Classic Editor. See Additional Notes for details.

Additional Notes

  • Via Quick Edit, entering a slug value "reserves" that slug if not already in use. If the slug is in use, a numeric value is appended to the slug (e.g. slug-already-used -> slug-already-used-1). This is visible after expanding Quick Edit again.
  • Via the block editor's Settings > Post > URL, interacting with the Permalink field attempts to "reserve" the slug. Upon save, if the slug is in use, a numeric value is appended to the slug. The final slug is displayed in the URL field.
  • Via the Classic Editor, modifying the permalink and saving the draft attempts to "reserve" the slug. If the slug is in use, a numeric value is appended to the slug. The final slug is displayed in the permalink.

#2 @hellofromTonya
13 months ago

  • Version trunk deleted

I'm doing triage in preparation for 6.2.0 RC1 on all tickets against trunk (which as the time of writing this comment, trunk is 6.2). Removing the Version as this does not appear to be a bug introduced in the 6.2 cycle.

Note: See TracTickets for help on using tickets.