WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#35529 assigned defect (bug)

Updating to 4.4.1 causes new pretty permalinks for media to break existing permalinks

Reported by: nyodulf Owned by: kraftbj
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Permalinks Keywords: permalinks media
Focuses: Cc:
PR Number:

Description

When updating a site from v4.0.9 to v4.4.1 at least one page (which is a top-level page for the site) is getting "-2" added on to its slug while an unattached image takes the original slug. This causes problems for SEO as well as breaking things that depend on results from functions like is_page('slug').

Change History (16)

#1 @wonderboymusic
4 years ago

  • Keywords changed from permalinks, media to permalinks media
  • Version changed from 4.4.1 to 4.4

See #1914

#2 @dd32
4 years ago

@nyodulf Can you explain how you updated? Did you do a manual update? An export/import? Did you use the in-dashboard update functionality?

The reason I ask this, is that the slugs should have stayed the same..

#3 @nyodulf
4 years ago

@dd32 It was a manual update using the in-dashboard functionality.

After some further testing, I got a slightly different result. This time the slug for the image and the slug for the page remained the same, which meant that clicking on the permalink in the images-edit screen brought me to the page.

However when I go to the edit screen for the *page*, the slug is shown with a "-2" suffix. (though hovering over the permalink shows the correct, unsuffixed URL in my browser's status bar). This remains the case even after re-saving the permalinks settings.

#4 @kraftbj
4 years ago

I didn't quite duplicate this, but got close.

Steps to duplicate:

  1. Starting with an older version of WP (core.svn/branches/4.0 in this case)
  2. Upload a media file directly to the media library with a simple name "picturetest.jpg", which auto-titles as "picturetest"
  3. Create a page with a matching title (e.g. "picturetest" which auto-slugs "picturetest")
  4. Update to trunk
  5. In the media library, the image has a slug displayed of "picturetest". The link displays the page, not the attachment page.
  6. Updating the media attachment updates the slug to the expected "picturetest-2"

#5 @nyodulf
4 years ago

@kraftbj - I mostly followed your procedure on a fresh install; differneces in bold:

  1. Starting with an older version of WP (core.svn/branches/4.0.9 in this case)
  2. Upload a media file directly to the media library with a simple name "picturetest.jpg", which auto-titles as "picturetest"
  3. Create a page with a matching title (e.g. "picturetest" which auto-slugs "picturetest")
  4. Update to latest via dashboard
    • Set permalink structure to /%postname%/
  5. In the media library, the image has a slug displayed of "picturetest". The link displays the page, not the attachment page.
    • On the page-edit screen things are quite strange; Visually the page's permalink is set to "pictureset-2" but hovering over it shows just "pictureset" in the browser status bar. So at this point, both items are actually pointing to /pictureset/, but the page is displaying the wrong info in the permalink.
  6. Updating the media attachment updates the slug to the expected "picturetest-2"
    • Updating the media attachment updates the visual display of the page slug to the expected "picturetest"

I realise this is different to what I originally posted. I'm sorry that I can't remember what the difference in the procedures between them was, that created the incorrectly functioning slug for the pre-existing page. It's possible that it was because the permalink structure was already set up, whereas this time I set it up after the update. I will test that tomorrow.

It does seem that something is amiss at the moment. As there is no way to bulk-update media items, this could result in a lot of broken media permalinks.

#6 @kraftbj
4 years ago

  • Milestone changed from Awaiting Review to 4.4.2

I ran into a case of this in the wild on dotcom as well.

#7 @nyodulf
4 years ago

A bit later than promised, but I ran the sequence above with the following changes:

  1. Starting with an older version of WP (core.svn/branches/4.0.9 in this case)
    • Set permalink structure to /%postname%/
  2. Upload a media file directly to the media library with a simple name "picturetest.jpg", which auto-titles as "picturetest"
  3. Create a page with a matching title (e.g. "picturetest" which auto-slugs "picturetest")
  4. Update to latest via dashboard
  5. In the media library, the image has a slug displayed of "picturetest". The link displays the page, not the attachment page.
    • On the page-edit screen things are quite strange; Visually the page's permalink is set to "pictureset-2" but hovering over it shows just "pictureset" in the browser status bar. So at this point, both items are actually pointing to /pictureset/, but the page is displaying the wrong info in the permalink.
  6. Updating the page updates the slug to "picturetest-2"

So in this version, the page's permalink is now broken, as per my original post. I don't know if it's specifically to do with setting the permalink structure before the update, but either way it's russian roulette as to how this process turns out, depending on which sequence you follow.

#8 @samuelsidler
4 years ago

  • Milestone changed from 4.4.2 to 4.5

This needs investigation and work before it can be targeted for 4.4.x. @kraftbj Want to take a stab at figuring this out for 4.5?

#9 @kraftbj
4 years ago

  • Owner set to kraftbj
  • Status changed from new to assigned

@samuelsidler I'll give it a spin and welcome other eyes too.

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


4 years ago

#11 @chriscct7
4 years ago

@kraftbj + @samuelsidler any thoughts on this one getting punted?

#12 @chriscct7
4 years ago

@dd32 as well

#13 @kraftbj
4 years ago

I've been able to duplicate it well, but haven't had a solid block of time to dive deep enough. I'll make one more push, but okay with punting.

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


4 years ago

#15 @chriscct7
4 years ago

  • Milestone changed from 4.5 to Future Release

Going to punt this out for now, but if it can be reliably reproduced and a patch comes in, it can be put back in.

#16 @mdgl
3 years ago

Related #34972.

Note: See TracTickets for help on using tickets.