Skip to content

Improved error handling for WXR file parsing#496

Open
girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/491
Open

Improved error handling for WXR file parsing#496
girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/491

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Checked that the WXR file exists and is valid. If not, then return an error message instead of proceeding with the import to prevent a fatal error.

Check before Pull Request is ready:

Closes #491

@girishpanchal30 girishpanchal30 requested a review from Copilot July 14, 2026 10:00
@girishpanchal30 girishpanchal30 added the pr-checklist-skip Allow this Pull Request to skip checklist. label Jul 14, 2026
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Jul 14, 2026
@pirate-bot

pirate-bot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Plugin build for d4df79e is ready 🛎️!

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the WXR SimpleXML parser to avoid PHP 8+ fatal errors when the WXR source is missing or empty by validating the file and its contents before calling DOMDocument::loadXML().

Changes:

  • Add filesystem existence check for the WXR file before attempting to parse it.
  • Add guard against empty/unreadable file contents to prevent loadXML( '' ) fatal errors.

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

Comment thread includes/Importers/WP/WXR_Parser_SimpleXML.php Outdated
Comment on lines +26 to +30
if ( ! $wp_filesystem->exists( $file ) ) {
return new WP_Error( 'SimpleXML_parse_error', 'The specified WXR file does not exist' );
}

$contents = $wp_filesystem->get_contents( $file );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants