Make WordPress Core

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#26871 closed defect (bug) (fixed)

wp_get_shortlink() returns post link for the home page

Reported by: nacin's profile nacin Owned by: nacin's profile nacin
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.7
Component: Posts, Post Types Keywords: has-patch commit
Focuses: Cc:

Description

wp_get_shortlink() was changed in [25030] to return links for public post types. It doesn't account for pages on the front page, though. Patch attached.

This was a regression from 3.6 -> 3.7.

Attachments (1)

26871.diff (792 bytes) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @nacin
11 years ago

  • Version set to 3.7

This triggered a curious (and major) bug on jquery.com, as they directed nginx to cache pages and redirects but did not have query strings in their cache key. ?p=X redirected to the home page, and this redirect got cached as / => /. Thus, the home page was issuing a 301 to itself. While I doubt this is going to be common at all, and the bug still existed (the link was simply broadcasted in this case), the front page is a prominent location and this is lame and crufty. Worth considering a point release fix; curious what others think.

#2 in reply to: ↑ 1 ; follow-up: @markjaquith
11 years ago

  • Keywords needs-patch added; has-patch removed

Patch attached.

Looks like you forgot it.

@nacin
11 years ago

#3 in reply to: ↑ 2 @nacin
11 years ago

Replying to markjaquith:

Patch attached.

Looks like you forgot it.

Thanks, 26871.diff.

#4 @samuelsidler
11 years ago

  • Keywords has-patch added; needs-patch removed

#5 @seanchayes
11 years ago

Tested this patch.

If the page in question is set as "Front Page displays: Front Page: <my test page>" then the "Get Shortlink" button does not appear next to the "View Page" button when editing the page.

When I change the "Front Page displays: Front Page" option to another page or "Your latest posts" and then go back to my page then the "Get Shortlink" button appears and can be used to get the page shortlink.

My guess is that is the required functionality although the patch, if I'm reading it correctly, would return the home_url if the "Get Shortlink" button was there, whereas I found that the button wasn't there to click in that scenario.

#6 @kirasong
10 years ago

  • Keywords commit added

Verified that the Get Shortlink button is not supposed to show when the shortlink is equal to the permalink.

26871.diff looks to work as described.

#7 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 27802:

Shortlinks: Use the home URL for a page on front.

This will result in 'Get Shortlink' hiding by default, as it will match the permalink (also the home URL).

fixes #26871.

#8 @nacin
10 years ago

In 27803:

Add a unit test for shortlinks of a page on front.

see #26871, see [27802].

#9 @cais
10 years ago

Unless the diff is not in enough context enough would it not create a "broken" link (sure, it will still be valid, it just may not be pointing to the correct address for the page) if the "home" page is changed?

Note: See TracTickets for help on using tickets.