Canonical / Query: Restore the is_404() check in wp_old_slug_redirect() which was removed in [34659].

This reverts part of [34659] due to excessive canonical problems it's caused in 4.4.x.

Remove the unit tests which are no longer supported.
This also removes the `is_feed()` code to avoid confusion - only pages & embeds will be redirected.

Merges [36280] and [36281] to trunk.

Props dd32.
See #21602, #35344.

git-svn-id: https://develop.svn.wordpress.org/trunk@37075 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2016-03-23 21:53:44 +00:00
parent 9f03a3bd5e
commit 0058968499
2 changed files with 3 additions and 64 deletions

View File

@@ -50,53 +50,6 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase {
$this->assertEquals( $permalink, $this->old_slug_redirect_url );
}
public function test_old_slug_redirect_endpoint() {
$old_permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'custom-endpoint' );
wp_update_post( array(
'ID' => $this->post_id,
'post_name' => 'bar-baz',
) );
$permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'custom-endpoint' );
$this->go_to( $old_permalink );
$GLOBALS['wp_query']->query_vars['custom-endpoint'] = true;
wp_old_slug_redirect();
$this->assertEquals( $permalink, $this->old_slug_redirect_url );
}
public function test_old_slug_redirect_endpoint_custom_query_var() {
$old_permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'second-endpoint' );
wp_update_post( array(
'ID' => $this->post_id,
'post_name' => 'bar-baz',
) );
$permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'second-endpoint' );
$this->go_to( $old_permalink );
$GLOBALS['wp_query']->query_vars['custom'] = true;
wp_old_slug_redirect();
$this->assertEquals( $permalink, $this->old_slug_redirect_url );
}
public function test_old_slug_redirect_feed() {
$old_permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'feed' );
wp_update_post( array(
'ID' => $this->post_id,
'post_name' => 'bar-baz',
) );
$permalink = user_trailingslashit( trailingslashit( get_permalink( $this->post_id ) ) . 'feed' );
$this->go_to( $old_permalink );
wp_old_slug_redirect();
$this->assertEquals( $permalink, $this->old_slug_redirect_url );
}
public function test_old_slug_redirect_attachment() {
$file = DIR_TESTDATA . '/images/canola.jpg';
$attachment_id = self::factory()->attachment->create_object( $file, $this->post_id, array(