Make WordPress Core

Opened 8 years ago

Last modified 6 years ago

#37156 new defect (bug)

Multisite: WP-generated permalink for title-less post does not work (Or: numeric post slug that matches existing post ID number generates 404 error)

Reported by: raskull's profile raskull Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4.3
Component: Posts, Post Types Keywords: reporter-feedback
Focuses: multisite Cc:

Description

On a Multisite installation, a permalink with a post-name structure results in a 404 error when its slug is a number and that number matches an existing post ID number. Example: http://myblog.com/blog/7 where a post (any post) has an ID of 7.

When WordPress generates a slug for a title-less post, it forms the slug using the post ID. Since the post ID is (now) in use, the default permalink for the title-less post is broken.

It appears ticket #5305 resolved the issue for regular installs by automatically appending -2 to the slug (http://myblog.com/blog/7-2). Can this be done for Multisite? Or better yet, use some other more elegant designation that doesn't imply that this is the second of two posts using 7 for the slug?

To replicate:
Use a Multisite installation.
Set permalinks to Post name structure.
Create a post without a title.
Note that the generated slug is the ID number of the post.
Save and then click on the Permalink slug below the title text field.
Arrive at 404 page.
In admin, change the slug to include a character.
Try again.
Arrive at correct page.

You can also see the same behavior by choosing any titled post in admin and changing its slug to a number that matches its own or any other existing ID.

Change History (5)

#1 @DrewAPicture
8 years ago

  • Component changed from General to Posts, Post Types

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


8 years ago

#3 follow-up: @flixos90
8 years ago

  • Keywords reporter-feedback added

Hi @raskull, and thanks for the report! Unfortunately I cannot replicate this, I did what you described, but it correctly appends the -2 suffix (also on multisite). Do you have any plugins active? Which version of WordPress are you using?

#4 in reply to: ↑ 3 ; follow-up: @raskull
8 years ago

Replying to flixos90:

Hi @raskull, and thanks for the report! Unfortunately I cannot replicate this, I did what you described, but it correctly appends the -2 suffix (also on multisite). Do you have any plugins active? Which version of WordPress are you using?

Hi @flixos90, I just updated to 4.6.1 on a multisite install. Subfolders, not subdomains. No active plugins. Same problem: Create a post without a title. The auto-generated slug is /blog/1502 where 1502 is the post ID. There is no -2 suffix appended.

I can see this behavior only on the main site; the subsites do append the -2. The difference seems to the insertion of blog/ to the url on the main site.

#5 in reply to: ↑ 4 @flixos90
8 years ago

@raskull Oh okay, I didn't use a subfolder setup, that's probably why it didn't happen for me. Will look at this again a little later.

Note: See TracTickets for help on using tickets.