Make WordPress Core

Changeset 62168


Ignore:
Timestamp:
03/27/2026 10:46:01 PM (11 hours ago)
Author:
peterwilsoncc
Message:

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.

Props peterwilsoncc, desrosj, westonruter, jorbin, mukesh27, czarate.
Fixes #64964.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r62075 r62168  
    688688                'show_in_rest'       => false,
    689689                'show_ui'            => false,
     690                'can_export'         => false,
    690691                'supports'           => array( 'custom-fields' ),
    691692            )
  • trunk/tests/phpunit/tests/admin/exportWp.php

    r61405 r62168  
    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}
Note: See TracChangeset for help on using the changeset viewer.