Skip to content

Various tweaks to import/export#4253

Merged
johngodley merged 2 commits into
trunkfrom
update/import-export-tweaks
Jul 9, 2026
Merged

Various tweaks to import/export#4253
johngodley merged 2 commits into
trunkfrom
update/import-export-tweaks

Conversation

@johngodley

Copy link
Copy Markdown
Owner

Various fixes for new import/export pages:

  • Group import now has update/create/ignore like redirects
  • Group import matches by name and updates existing
  • Apache import detects a few more regex situations
  • Style fixes to imports

Copilot AI review requested due to automatic review settings July 9, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 (replacing groups_imported) across PHP + UI and extend test coverage for the new group-duplicate behaviors.
  • Enhance Apache RewriteRule parsing to better detect standard (non-regex) cases and to capture additional match flags into match_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 ., and regex_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 thread includes/import-export/class-format-handler.php
Comment thread includes/import-export/class-format-handler.php

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

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,
@johngodley johngodley merged commit e7e1881 into trunk Jul 9, 2026
9 checks passed
@johngodley johngodley deleted the update/import-export-tweaks branch July 9, 2026 16:56
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.

2 participants