Skip to content

Reuse existing JSON groups#4238

Merged
johngodley merged 2 commits into
trunkfrom
update/reuse-json-group
Jun 22, 2026
Merged

Reuse existing JSON groups#4238
johngodley merged 2 commits into
trunkfrom
update/reuse-json-group

Conversation

@johngodley

Copy link
Copy Markdown
Owner

When importing JSON, re-use any group if it already exists

Copilot AI review requested due to automatic review settings June 22, 2026 05:30

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

Updates the JSON import path to re-use existing redirect groups when an incoming JSON group references an ID that already exists in the database, instead of always creating a new group. This aligns JSON imports with real-world scenarios where exports/imports may be repeated into the same site.

Changes:

  • Refactors JSON import group mapping to resolve group IDs via a new get_group_id() helper that prefers existing groups.
  • Ensures missing group IDs referenced by redirects create a single fallback “Group” per distinct missing ID (via mapping reuse).
  • Adds integration tests covering “reuse existing group ID” and “single fallback group per missing ID”.

Reviewed changes

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

File Description
tests/integration/fileio/test-json.php Adds integration coverage for reusing existing groups and for fallback-group behavior when group IDs are missing.
includes/fileio/format/class-json.php Refactors JSON import to resolve group IDs through get_group_id() and re-use existing groups when present.

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

@johngodley johngodley merged commit 00e276a into trunk Jun 22, 2026
8 checks passed
@johngodley johngodley deleted the update/reuse-json-group branch June 22, 2026 05:43
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