-
Notifications
You must be signed in to change notification settings - Fork 83
Fix Mastodon import for archives with nested root folder #2581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 fixes an issue where Mastodon archive imports fail when the archive contains a nested root folder structure. The fix detects and handles archives where files are wrapped in a single root directory (e.g., archive-name/outbox.json) instead of being at the root level.
Key Changes:
- Added
maybe_unwrap_archive()method to detect and handle nested archive structures - Replaced
dirlist()check with$wp_filesystem->exists()for better performance - Replaced
file_get_contents()with$wp_filesystem->get_contents()for consistency
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| includes/wp-admin/import/class-mastodon.php | Added archive unwrapping logic and improved file system operations for consistency |
| .github/changelog/2581-from-description | Added changelog entry documenting the bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Is it possible to somehow test this with a unittest? |
It is! Fixed in b17eede. |
Fixes https://wordpress.org/support/topic/import-mastodon-beta/page/2/#post-18741275
Proposed changes:
archive-name/outbox.jsoninstead ofoutbox.jsonat root level).$wp_filesystem->exists()instead ofdirlist()for checkingoutbox.jsonexistence (more efficient).$wp_filesystem->get_contents()instead offile_get_contents()for consistency with the rest of the codebase and to remove phpcs ignore comment.Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Fix Mastodon import for archives with nested root folder.