Skip to content

Commit e53054b

Browse files
committed
Exports: Exclude wp_sync_storage post type from exports.
Configured the Real Time Collaboration post type to be excluded from exports by default. The data is considered ephemeral and includes data on post IDs that may not match the IDs of posts on the importing site. Introduces a test to the export test suite to ensure that post types set to be excluded from exports are, in fact, excluded from exports. Reviewed by westonruter, desrosj, jorbin. Merges r62168 to the 7.0 branch. Props peterwilsoncc, desrosj, westonruter, jorbin, mukesh27, czarate. Fixes #64964. git-svn-id: https://develop.svn.wordpress.org/branches/7.0@62169 602fd350-edb4-49c9-b593-d223f7449a82
1 parent dcaa08f commit e53054b

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/wp-includes/post.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ function create_initial_post_types() {
687687
'show_in_menu' => false,
688688
'show_in_rest' => false,
689689
'show_ui' => false,
690+
'can_export' => false,
690691
'supports' => array( 'custom-fields' ),
691692
)
692693
);

tests/phpunit/tests/admin/exportWp.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,41 @@ public function test_export_with_null_term_meta_values() {
474474
$this->assertNotFalse( $xml, 'Export should not fail with NULL term meta values' );
475475
$this->assertGreaterThan( 0, count( $xml->channel->item ), 'Export should contain items' );
476476
}
477+
478+
/**
479+
* Ensure that posts types with 'can_export' set to false are not included in the export.
480+
*
481+
* @ticket 64964
482+
*/
483+
public function test_export_does_not_include_excluded_post_types() {
484+
register_post_type(
485+
'wpexport_excluded',
486+
array( 'can_export' => false )
487+
);
488+
489+
$excluded_post_id = self::factory()->post->create(
490+
array(
491+
'post_title' => 'Excluded Post Type',
492+
'post_type' => 'wpexport_excluded',
493+
'post_status' => 'publish',
494+
)
495+
);
496+
497+
$xml = $this->get_the_export(
498+
array(
499+
'content' => 'all',
500+
)
501+
);
502+
503+
$found_post = false;
504+
foreach ( $xml->channel->item as $item ) {
505+
$wp_item = $item->children( 'wp', true );
506+
if ( (int) $wp_item->post_id === $excluded_post_id ) {
507+
$found_post = true;
508+
break;
509+
}
510+
}
511+
512+
$this->assertFalse( $found_post, 'Posts of excluded post types should not be included in export' );
513+
}
477514
}

0 commit comments

Comments
 (0)