From fe1df4023c8344dd4bb21035563e58ddd1731949 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Thu, 25 Jan 2024 17:34:54 +0000 Subject: [PATCH] Media: Redirect inactive attachment pages for logged-out users. Ensure logged out users are redirected to the media file when attachment pages are inactive. This removes the read_post capability check from the canonical redirects as anonymous users lack the permission. This was previously committed in [57310] before being reverted in [57318]. This update includes a fix to cover instances where revealing a URL could be considered a data leak and greatly expands the unit tests to ensure that this is covered along with many other instances. Follow-up to [56657], [56658], [56711], [57310], [57318]. Props peterwilsoncc, jorbin, afercia, aristath, chesio, joppuyo, jorbin, lakshmananphp, poena, sergeybiryukov, swissspidy, johnbillion. Fixes #59866. See #57913. git-svn-id: https://develop.svn.wordpress.org/trunk@57357 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/canonical.php | 22 +- tests/phpunit/tests/canonical.php | 72 +- tests/phpunit/tests/canonical/postStatus.php | 771 ++++++++++++++++++- 3 files changed, 835 insertions(+), 30 deletions(-) diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php index 0b94791fd9b45..093493731f91a 100644 --- a/src/wp-includes/canonical.php +++ b/src/wp-includes/canonical.php @@ -550,13 +550,23 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $is_attachment_redirect = false; if ( is_attachment() && ! get_option( 'wp_attachment_pages_enabled' ) ) { - $attachment_id = get_query_var( 'attachment_id' ); - - if ( current_user_can( 'read_post', $attachment_id ) ) { - $redirect_url = wp_get_attachment_url( $attachment_id ); - - $is_attachment_redirect = true; + $attachment_id = get_query_var( 'attachment_id' ); + $attachment_post = get_post( $attachment_id ); + $attachment_parent_id = $attachment_post ? $attachment_post->post_parent : 0; + + $attachment_url = wp_get_attachment_url( $attachment_id ); + if ( $attachment_url !== $redirect_url ) { + /* + * If an attachment is attached to a post, it inherits the parent post's status. Fetch the + * parent post to check its status later. + */ + if ( $attachment_parent_id ) { + $redirect_obj = get_post( $attachment_parent_id ); + } + $redirect_url = $attachment_url; } + + $is_attachment_redirect = true; } $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php index 35bde13937dc3..4a0a85d1ad198 100644 --- a/tests/phpunit/tests/canonical.php +++ b/tests/phpunit/tests/canonical.php @@ -14,7 +14,7 @@ public function set_up() { parent::set_up(); wp_set_current_user( self::$author_id ); - add_filter( 'pre_option_wp_attachment_pages_enabled', '__return_true' ); + update_option( 'wp_attachment_pages_enabled', 1 ); } /** @@ -407,23 +407,83 @@ public function test_feed_canonical_with_not_exists_query() { } /** + * Test canonical redirects for attachment pages when the option is disabled. + * * @ticket 57913 + * @ticket 59866 + * + * @dataProvider data_canonical_attachment_page_redirect_with_option_disabled */ - public function test_canonical_attachment_page_redirect_with_option_disabled() { - add_filter( 'pre_option_wp_attachment_pages_enabled', '__return_false' ); + public function test_canonical_attachment_page_redirect_with_option_disabled( $expected, $user = null, $parent_post_status = '' ) { + update_option( 'wp_attachment_pages_enabled', 0 ); + + if ( '' !== $parent_post_status ) { + $parent_post_id = self::factory()->post->create( + array( + 'post_status' => $parent_post_status, + ) + ); + } else { + $parent_post_id = 0; + } $filename = DIR_TESTDATA . '/images/test-image.jpg'; $contents = file_get_contents( $filename ); $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); - $attachment_id = $this->_make_attachment( $upload ); + $attachment_id = $this->_make_attachment( $upload, $parent_post_id ); + $attachment_url = wp_get_attachment_url( $attachment_id ); $attachment_page = get_permalink( $attachment_id ); + // Set as anonymous/logged out user. + if ( null !== $user ) { + wp_set_current_user( $user ); + } + $this->go_to( $attachment_page ); - $url = redirect_canonical( $attachment_page, false ); - $expected = wp_get_attachment_url( $attachment_id ); + $url = redirect_canonical( $attachment_page, false ); + if ( is_string( $expected ) ) { + $expected = str_replace( '%%attachment_url%%', $attachment_url, $expected ); + } $this->assertSame( $expected, $url ); } + + /** + * Data provider for test_canonical_attachment_page_redirect_with_option_disabled(). + * + * @return array[] + */ + public function data_canonical_attachment_page_redirect_with_option_disabled() { + return array( + 'logged out user, no parent' => array( + '%%attachment_url%%', + 0, + ), + 'logged in user, no parent' => array( + '%%attachment_url%%', + ), + 'logged out user, private parent' => array( + null, + 0, + 'private', + ), + 'logged in user, private parent' => array( + '%%attachment_url%%', + null, + 'private', + ), + 'logged out user, public parent' => array( + '%%attachment_url%%', + 0, + 'publish', + ), + 'logged in user, public parent' => array( + '%%attachment_url%%', + null, + 'publish', + ), + ); + } } diff --git a/tests/phpunit/tests/canonical/postStatus.php b/tests/phpunit/tests/canonical/postStatus.php index 9b68e61f36dc9..7620ccfdd19f7 100644 --- a/tests/phpunit/tests/canonical/postStatus.php +++ b/tests/phpunit/tests/canonical/postStatus.php @@ -169,8 +169,6 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { public function set_up() { parent::set_up(); self::setup_custom_types(); - - add_filter( 'pre_option_wp_attachment_pages_enabled', '__return_true' ); } /** @@ -223,8 +221,15 @@ public static function setup_custom_types() { * @param string $user_role User role. * @param string $requested Requested URL. * @param string $expected Expected URL. + * @param string $enable_attachment_pages Whether to enable attachment pages. Default true. */ - public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_role, $requested, $expected ) { + public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_role, $requested, $expected, $enable_attachment_pages = true ) { + if ( $enable_attachment_pages ) { + update_option( 'wp_attachment_pages_enabled', 1 ); + } else { + update_option( 'wp_attachment_pages_enabled', 0 ); + } + wp_set_current_user( self::$users[ $user_role ] ); $this->set_permalink_structure( '' ); $post = self::$posts[ $post_key ]; @@ -243,12 +248,7 @@ public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_r /** * Data provider for test_canonical_redirects_to_plain_permalinks. * - * @return array[] Array of arguments for tests { - * @type string $post_key Post key used for creating fixtures. - * @type string $user_role User role. - * @type string $requested Requested URL. - * @type string $expected Expected URL. - * } + * @return array[] */ public function data_canonical_redirects_to_plain_permalinks() { $data = array(); @@ -273,6 +273,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, ); $data[] = array( @@ -280,6 +289,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + false, ); // Ensure rss redirects to rss2. @@ -288,6 +306,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss2&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss2&p=%ID%', + false, ); // Ensure rss redirects to rss2. @@ -296,6 +323,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss2&page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss2&page_id=%ID%', + false, ); } } @@ -311,6 +347,23 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + true, ); $data[] = array( @@ -318,6 +371,7 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + false, ); // Ensure rss redirects to rss2. @@ -326,6 +380,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss2&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss2&p=%ID%', + false, ); // Ensure rss redirects to rss2. @@ -334,6 +397,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss2&page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss2&page_id=%ID%', + false, ); } @@ -347,6 +419,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, ); $data[] = array( @@ -354,6 +435,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + false, ); // Ensure post's existence is not demonstrated by changing rss to rss2. @@ -362,6 +452,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); // Ensure post's existence is not demonstrated by changing rss to rss2. @@ -370,6 +469,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss&page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss&page_id=%ID%', + false, ); } } @@ -385,6 +493,23 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + true, ); $data[] = array( @@ -392,6 +517,7 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + false, ); // Ensure post's existence is not demonstrated by changing rss to rss2. @@ -400,6 +526,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); // Ensure post's existence is not demonstrated by changing rss to rss2. @@ -408,6 +543,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss&page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss&page_id=%ID%', + false, ); } } @@ -423,6 +567,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, ); $data[] = array( @@ -430,6 +583,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + false, ); // Ensure post's existence is not demonstrated by changing rss to rss2. @@ -438,6 +600,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); // Ensure post's existence is not demonstrated by changing rss to rss2. @@ -446,6 +617,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss&page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss&page_id=%ID%', + false, ); } } @@ -457,6 +637,23 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?p=%ID%', '/?a-public-cpt=a-public-cpt', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?a-public-cpt=a-public-cpt', + false, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + true, ); $data[] = array( @@ -464,6 +661,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key&post_type=$post_key", + "/?name=$post_key&post_type=$post_key", + true, ); $data[] = array( @@ -471,6 +677,7 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key&post_type=$post_key", "/?name=$post_key&post_type=$post_key", + false, ); // Ensure rss is replaced by rss2. @@ -479,6 +686,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?a-public-cpt=a-public-cpt&feed=rss2', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?a-public-cpt=a-public-cpt&feed=rss2', + false, ); } @@ -488,6 +704,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, ); $data[] = array( @@ -495,6 +720,23 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key&post_type=$post_key", + "/?name=$post_key&post_type=$post_key", + true, ); $data[] = array( @@ -502,6 +744,7 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key&post_type=$post_key", "/?name=$post_key&post_type=$post_key", + false, ); // Ensure rss is not replaced with rss2. @@ -510,6 +753,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); } } @@ -521,6 +773,23 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + true, ); $data[] = array( @@ -528,6 +797,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key&post_type=$post_key", + "/?name=$post_key&post_type=$post_key", + true, ); $data[] = array( @@ -535,6 +813,15 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, "/?name=$post_key&post_type=$post_key", "/?name=$post_key&post_type=$post_key", + false, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + true, ); $data[] = array( @@ -542,6 +829,7 @@ public function data_canonical_redirects_to_plain_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + false, ); } } @@ -559,8 +847,15 @@ public function data_canonical_redirects_to_plain_permalinks() { * @param string $user_role User role. * @param string $requested Requested URL. * @param string $expected Expected URL. + * @param string $enable_attachment_pages Whether to enable attachment pages. Default true. */ - public function test_canonical_redirects_to_pretty_permalinks( $post_key, $user_role, $requested, $expected ) { + public function test_canonical_redirects_to_pretty_permalinks( $post_key, $user_role, $requested, $expected, $enable_attachment_pages = true ) { + if ( $enable_attachment_pages ) { + update_option( 'wp_attachment_pages_enabled', 1 ); + } else { + update_option( 'wp_attachment_pages_enabled', 0 ); + } + wp_set_current_user( self::$users[ $user_role ] ); $this->set_permalink_structure( '/%postname%/' ); $post = self::$posts[ $post_key ]; @@ -605,6 +900,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', "/$post_key-post/", + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + "/$post_key-post/", + false, ); $data[] = array( @@ -612,27 +916,63 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', "/$post_key-post/$post_key-inherited-attachment/", + true, ); $data[] = array( - "$post_key-page", + "$post_key-attachment", $user, - '/?post_type=page&p=%ID%', - "/$post_key-page/", + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, ); $data[] = array( "$post_key-page", $user, - '/?page_id=%ID%', + '/?post_type=page&p=%ID%', "/$post_key-page/", + true, ); $data[] = array( - $post_key, + "$post_key-page", $user, - "/?name=$post_key-post", - "/$post_key-post/", + '/?post_type=page&p=%ID%', + "/$post_key-page/", + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?page_id=%ID%', + "/$post_key-page/", + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?page_id=%ID%', + "/$post_key-page/", + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/$post_key-post/", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/$post_key-post/", + false, ); $data[] = array( @@ -640,6 +980,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', "/$post_key-post/feed/", + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + "/$post_key-post/feed/", + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + "/$post_key-page/feed/", + true, ); $data[] = array( @@ -647,6 +1004,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&page_id=%ID%', "/$post_key-page/feed/", + false, ); } } @@ -658,6 +1016,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', "/$post_key-post/", + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + "/$post_key-post/", + false, ); $data[] = array( @@ -665,6 +1032,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', "/$post_key-post/$post_key-inherited-attachment/", + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + "/$post_key-page/", + true, ); $data[] = array( @@ -672,6 +1056,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?post_type=page&p=%ID%', "/$post_key-page/", + false, ); $data[] = array( @@ -679,6 +1064,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?page_id=%ID%', "/$post_key-page/", + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?page_id=%ID%', + "/$post_key-page/", + false, ); $data[] = array( @@ -686,6 +1080,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key-post", "/$post_key-post/", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/$post_key-post/", + false, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + "/$post_key-post/feed/", + true, ); $data[] = array( @@ -693,6 +1104,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', "/$post_key-post/feed/", + false, ); $data[] = array( @@ -700,6 +1112,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&page_id=%ID%', "/$post_key-page/feed/", + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + "/$post_key-page/feed/", + false, ); } @@ -709,6 +1130,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + true, ); $data[] = array( @@ -716,6 +1154,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + false, ); $data[] = array( @@ -723,6 +1162,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, ); $data[] = array( @@ -730,6 +1178,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?page_id=%ID%', '/?page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?page_id=%ID%', + '/?page_id=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + true, ); $data[] = array( @@ -737,6 +1202,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + false, ); $data[] = array( @@ -744,6 +1210,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); $data[] = array( @@ -751,6 +1226,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss&page_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss&page_id=%ID%', + false, ); } } @@ -762,6 +1246,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', "/$post_key/$post_key/", + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + "/$post_key/$post_key/", + false, ); $data[] = array( @@ -769,6 +1262,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', "/$post_key/$post_key/$post_key-inherited-attachment/", + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, ); $data[] = array( @@ -776,6 +1278,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key&post_type=$post_key", "/$post_key/$post_key/?post_type=$post_key", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key&post_type=$post_key", + "/$post_key/$post_key/?post_type=$post_key", + false, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + "/$post_key/$post_key/feed/", + true, ); $data[] = array( @@ -783,6 +1302,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', "/$post_key/$post_key/feed/", + false, ); } @@ -792,6 +1312,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, ); $data[] = array( @@ -799,6 +1328,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key&post_type=$post_key", + "/?name=$post_key&post_type=$post_key", + true, ); $data[] = array( @@ -806,6 +1352,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key&post_type=$post_key", "/?name=$post_key&post_type=$post_key", + false, ); $data[] = array( @@ -813,6 +1360,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); } } @@ -824,6 +1380,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + true, ); $data[] = array( @@ -831,7 +1404,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', - // "/$post_key-inherited-attachment/", + false, ); $data[] = array( @@ -839,6 +1412,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key&post_type=$post_key", "/?name=$post_key&post_type=$post_key", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key&post_type=$post_key", + "/?name=$post_key&post_type=$post_key", + false, ); $data[] = array( @@ -846,6 +1428,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, ); } } @@ -857,6 +1448,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, ); $data[] = array( @@ -864,6 +1464,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, ); $data[] = array( @@ -871,6 +1480,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?page_id=%ID%', + '/?page_id=%ID%', + true, ); $data[] = array( @@ -878,6 +1504,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?page_id=%ID%', '/?page_id=%ID%', + false, ); $data[] = array( @@ -885,6 +1512,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + false, ); $data[] = array( @@ -892,6 +1528,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss&page_id=%ID%', + true, ); $data[] = array( @@ -899,6 +1552,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss&page_id=%ID%', + false, ); } } @@ -910,6 +1564,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?p=%ID%', '/?p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?p=%ID%', + '/?p=%ID%', + false, ); $data[] = array( @@ -917,6 +1580,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?attachment_id=%ID%', '/?attachment_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/?attachment_id=%ID%', + '/?attachment_id=%ID%', + false, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/trash-post/trash-post-inherited-attachment/', + '/?attachment_id=%ID%', + true, ); $data[] = array( @@ -924,6 +1604,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/trash-post/trash-post-inherited-attachment/', '/?attachment_id=%ID%', + false, ); $data[] = array( @@ -931,6 +1612,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/trash-post__trashed/trash-post-inherited-attachment/', '/?attachment_id=%ID%', + true, + ); + + $data[] = array( + "$post_key-attachment", + $user, + '/trash-post__trashed/trash-post-inherited-attachment/', + '/?attachment_id=%ID%', + false, ); $data[] = array( @@ -938,6 +1628,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?post_type=page&p=%ID%', '/?post_type=page&p=%ID%', + true, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?post_type=page&p=%ID%', + '/?post_type=page&p=%ID%', + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?page_id=%ID%', + '/?page_id=%ID%', + true, ); $data[] = array( @@ -945,6 +1652,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?page_id=%ID%', '/?page_id=%ID%', + false, ); $data[] = array( @@ -952,6 +1660,15 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, "/?name=$post_key-post", "/?name=$post_key-post", + true, + ); + + $data[] = array( + $post_key, + $user, + "/?name=$post_key-post", + "/?name=$post_key-post", + false, ); $data[] = array( @@ -959,6 +1676,23 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&p=%ID%', '/?feed=rss&p=%ID%', + true, + ); + + $data[] = array( + $post_key, + $user, + '/?feed=rss&p=%ID%', + '/?feed=rss&p=%ID%', + false, + ); + + $data[] = array( + "$post_key-page", + $user, + '/?feed=rss&page_id=%ID%', + '/?feed=rss&page_id=%ID%', + true, ); $data[] = array( @@ -966,6 +1700,7 @@ public function data_canonical_redirects_to_pretty_permalinks() { $user, '/?feed=rss&page_id=%ID%', '/?feed=rss&page_id=%ID%', + false, ); } }