Various tweaks to import/export#4253
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the import/export experience by expanding group-import duplicate handling (create/update/ignore), improving Apache rewrite-rule detection/normalization, and polishing the import/export UI + result reporting.
Changes:
- Update import stats to track
groups_updated/groups_ignored(replacinggroups_imported) across PHP + UI and extend test coverage for the new group-duplicate behaviors. - Enhance Apache
RewriteRuleparsing to better detect standard (non-regex) cases and to capture additional match flags intomatch_data. - UI/UX tweaks: simplify ImportPage button labels, adjust import options visibility/messages, improve preview table layout, and show export “File size”.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test-plugin-importers.php | Updates expected import stats keys for group tracking. |
| tests/unit/test-import-export-services.php | Updates expected service return stats for group tracking. |
| tests/unit/test-apache-format.php | Adds coverage for unescaped dot handling and optional trailing slash rewrite imports. |
| tests/integration/import-export/test-json.php | Adds integration coverage for group create/update/ignore counts and name matching. |
| src/page/import/use-import-page.ts | Updates empty import stats shape for new group counters. |
| src/page/import/types.ts | Updates ImportStats typing for new group counters. |
| src/page/import/index.tsx | Simplifies ImportPage button labels (“Preview”/“Import”). |
| src/page/import/index.test.tsx | Refactors test setup and adds coverage for options visibility/disabled actions. |
| src/page/import/import-results.tsx | Updates empty-result detection + stats labels and restructures preview rendering within IoCard. |
| src/page/import/import-results.test.tsx | Updates assertions for new labels/counters and preview-table structure. |
| src/page/import/import-options.tsx | Tightens option visibility logic and updates duplicate-mode label copy. |
| src/page/export/export-results.tsx | Adds formatFileSize() and displays export payload size. |
| src/page/export/export-results.test.tsx | Adds coverage for export “File size” display. |
| src/lib/api/hooks/use-io.ts | Updates import notice string to reflect new group counters and revised “ignored” phrasing. |
| src/component/import-export/style.scss | Adds stacked control layout and adjusts preview table spacing. |
| includes/import-export/importer/class-wordpress-old-slugs.php | Updates importer result shape for new group counters. |
| includes/import-export/importer/class-safe-redirect-manager.php | Updates importer result shape for new group counters. |
| includes/import-export/importer/class-plugin.php | Updates empty/results payload keys for new group counters. |
| includes/import-export/importer/class-plugin-registry.php | Updates fallback result payload keys for new group counters. |
| includes/import-export/format/class-json.php | Routes group import through ImportGroup resolver rather than local counting logic. |
| includes/import-export/format/class-apache.php | Improves RewriteRule handling (optional trailing slash) and adds match_data extraction + dot unescaping. |
| includes/import-export/class-import-group.php | Implements group duplicate modes and name-based matching, tracking created/updated/ignored counts. |
| includes/import-export/class-group-repository.php | Adds get_by_name() and update() to support new ImportGroup behaviors. |
| includes/import-export/class-format-handler.php | Updates ImportResult contract and result assembly for new group counters. |
Comments suppressed due to low confidence (1)
includes/import-export/format/class-apache.php:243
decode_url()now unescapes\.to., andregex_url()uses the decoded value when returning a regex pattern. For rules that remain regex (e.g.^foo\.bar$), this changes the meaning from a literal dot to a wildcard dot, so the imported regex will match unintended URLs. Preserve escaped dots when constructing the returned regex pattern, while still unescaping dots for the standard/non-regex URL cases.
$url = $this->decode_url( $url );
if ( $this->is_str_regex( $url ) ) {
$has_start = strpos( $url, '^' ) === 0;
$has_end = $this->has_end_anchor( $url );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
30
to
+36
| * @phpstan-type ImportResult array{ | ||
| * created: int, | ||
| * updated: int, | ||
| * ignored: int, | ||
| * groups_created: int, | ||
| * groups_imported: int, | ||
| * groups_updated: int, | ||
| * groups_ignored: int, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Various fixes for new import/export pages: