Canonical: after [34272], don't redirect rewrite endpoints on attachment URLs when pretty permalinks are enabled.

Fixes #19918.

Built from https://develop.svn.wordpress.org/trunk@34643


git-svn-id: http://core.svn.wordpress.org/trunk@34607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-27 22:11:25 +00:00
parent 61196c4862
commit 8cd1db9c9c
2 changed files with 5 additions and 3 deletions

View File

@ -39,7 +39,7 @@
* @return string|void The string of the URL, if redirect needed.
*/
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
return;
@ -157,7 +157,9 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
if ( is_attachment() && ! $redirect_url ) {
if ( is_attachment() &&
! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) &&
! $redirect_url ) {
if ( ! empty( $_GET['attachment_id'] ) ) {
$redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
if ( $redirect_url ) {

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34642';
$wp_version = '4.4-alpha-34643';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.