From 8cd1db9c9cd25aa2d4bd4abdd66be98bc0f9d5cc Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 27 Sep 2015 22:11:25 +0000 Subject: [PATCH] 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 --- wp-includes/canonical.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index 52850b4017..3a30b47e00 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -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 ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 1d469e4f88..954c8a4005 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.