WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#35407 closed defect (bug) (fixed)

set_url_scheme() called inconsistently on URLs passed to `preview_post_link` filter

Reported by: danielbachhuber Owned by: jeremyfelt
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Posts, Post Types Keywords: has-patch https
Focuses: Cc:

Description

It'd expect it to be consistently applied to URLs passed to preview_post_link, instead of applied in some cases and not applied in other cases.

In WordPress 4.4, get_preview_post_link() was introduced with an optional third argument $preview_link. In the cases where the $preview_link is supplied in the codebase, the permalink is primed with set_url_scheme(). However, internally, get_preview_post_link() defines the preview link without running it through set_url_scheme().

Pragmatically, it appears only edit-form-advanced.php is affected by this issue.

I discovered this issue while debugging a site where the admin is served over SSL with a different domain. However, I don't feel wholly confident in how WordPress generates URLs in this scenario.

Attachments (2)

35407.1.diff (591 bytes) - added by danielbachhuber 5 years ago.
35407.diff (2.6 KB) - added by jeremyfelt 5 years ago.

Download all attachments as: .zip

Change History (8)

#1 @johnbillion
5 years ago

  • Keywords https added

#2 @mikeschroder
5 years ago

@johnbillion @jeremyfelt Who would be best to own this? Are you thinking you'd like to tackle it for 4.5 still?

#3 @jeremyfelt
5 years ago

  • Owner set to jeremyfelt
  • Status changed from new to accepted

I'll take a closer look at this today and tomorrow.

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


5 years ago

@jeremyfelt
5 years ago

#5 @jeremyfelt
5 years ago

  • Version set to 4.4

It looks like there are a couple places that lost their preview link set_url_scheme() in [34170] and a handful of other places that did not need to pass the third argument.

35407.diff cleans up a couple of these for consistency.

#6 @jeremyfelt
5 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 36926:

Posts: Call set_url_scheme() consistently on URLs passed through preview_post_link

After [34170], some preview URLs that passed through set_url_scheme() no longer do so. We can restore that behavior by applying set_url_scheme() whenever get_preview_post_link() provides the URL.

Props danielbachhuber.
Fixes #35407.

Note: See TracTickets for help on using tickets.