Skip to content

Conversation

@kiranpotphode
Copy link

This PR introduces --skip_authors and --skip_terms flags for wp export command.

Fixes: #72

@kiranpotphode kiranpotphode marked this pull request as ready for review July 18, 2024 13:57
@kiranpotphode kiranpotphode requested a review from a team as a code owner July 18, 2024 13:57
@codecov
Copy link

codecov bot commented Mar 12, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@swissspidy swissspidy requested a review from Copilot November 2, 2025 14:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to skip authors and terms (categories, tags, custom taxonomy terms, and nav menu terms) from WordPress export files. The implementation follows the existing pattern used by the --skip_comments flag.

Key Changes:

  • Added --skip_authors and --skip_terms command-line flags
  • Implemented exclusion mechanism in WP_Export_Split_Files_Writer to filter out specified sections
  • Modified before_posts() method signature to accept available sections parameter

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Export_Command.php Added CLI parameters and validation methods for --skip_authors and --skip_terms flags, populating the $exclude array based on user input
src/WP_Export_Split_Files_Writer.php Implemented section exclusion logic and updated before_posts() call to pass filtered sections
features/export.feature Added test scenarios for the new skip flags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +48 to +55
if ( ! empty( $writer_args['exclude'] ) ) {
foreach ( $writer_args['exclude'] as $exclude ) {
$key = array_search( $exclude, $this->available_sections, true );
if ( false !== $key ) {
unset( $this->available_sections[ $key ] );
}
}
}
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exclusion logic removes sections from $this->available_sections after it has already been used to calculate $this->subsequent_sections (line 45). This means excluded sections will still be present in subsequent files when using --include_once. The exclusion logic should be moved before line 44 to ensure excluded sections are properly removed from both $this->available_sections and $this->subsequent_sections.

Copilot uses AI. Check for mistakes.
Comment on lines +193 to +196
if ( $this->export_args['skip_authors'] ) {
$this->exclude[] = 'authors';
}

Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --skip_terms flag excludes sections but does not update $this->export_args['skip_terms'] at the point of exclusion. The validation method check_skip_terms() (line 514-525) will set this value later during validation, but this creates a potential inconsistency if validation order changes. Additionally, the --stdout mode uses WP_Export_File_Writer which doesn't support the exclusion mechanism. When --stdout is used with --skip_authors or --skip_terms, the sections will still be included in the output since WP_Export_File_Writer calls before_posts() without parameters.

Suggested change
if ( $this->export_args['skip_authors'] ) {
$this->exclude[] = 'authors';
}
// Re-calculate exclusions after validation to ensure consistency.
$this->exclude = [];
if ( $this->export_args['skip_authors'] ) {
$this->exclude[] = 'authors';
}

Copilot uses AI. Check for mistakes.
"""
And the {EXPORT_FILE} file should not contain:
"""
<wp:tags>
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML tag <wp:tags> appears to be incorrect. Based on WordPress WXR format standards, tags are typically represented as <wp:tag>, not <wp:tags> (note the singular form). This test assertion may not work as expected.

Suggested change
<wp:tags>
<wp:tag>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lite export

1 participant