Skip to content

GH#1503: guard invalid site duplication source#1538

Merged
superdav42 merged 1 commit into
mainfrom
feature/salvage-pr1521-site-duplicator-guard
Jun 24, 2026
Merged

GH#1503: guard invalid site duplication source#1538
superdav42 merged 1 commit into
mainfrom
feature/salvage-pr1521-site-duplicator-guard

Conversation

@superdav42

@superdav42 superdav42 commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Verification

  • vendor/bin/phpunit --filter test_duplicate_invalid_source_site
  • vendor/bin/phpunit --filter Site_Duplicator_Test
  • vendor/bin/phpcs inc/helpers/class-site-duplicator.php tests/WP_Ultimo/Helpers/Site_Duplicator_Test.php
  • Pre-commit hook: PHPCS and PHPStan passed for staged PHP files

For #1503
Supersedes #1521


aidevops.sh v3.22.0 plugin for OpenCode v1.17.9 with gpt-5.5 salvaged closed PR #1521 in a headless run.

Summary by CodeRabbit

  • Bug Fixes
    • Improved site duplication error handling by validating the source site exists before processing.
    • Users now receive clear, localized error messages when attempting to duplicate from an invalid source site.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a07df389-46b2-4aa9-a1a3-b51012e6bfea

📥 Commits

Reviewing files that changed from the base of the PR and between a76c505 and 8c6d23b.

📒 Files selected for processing (2)
  • inc/helpers/class-site-duplicator.php
  • tests/WP_Ultimo/Helpers/Site_Duplicator_Test.php

📝 Walkthrough

Walkthrough

duplicate_site() now calls get_site($from_site_id) before running duplication; if the site is not found, it returns a WP_Error with code source_template_site_not_found. The corresponding test is updated to assert that specific error code instead of accepting multiple result shapes.

Changes

Source site validation guard

Layer / File(s) Summary
Source site guard and test assertion
inc/helpers/class-site-duplicator.php, tests/WP_Ultimo/Helpers/Site_Duplicator_Test.php
duplicate_site() fetches the source site via get_site($from_site_id) and short-circuits with a WP_Error (source_template_site_not_found) when missing; duplication arguments are only populated and process_duplication() only called when the site exists. The test tightens its assertion to require both a WP_Error return and the exact source_template_site_not_found error code.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

review-feedback-scanned

Poem

🐇 A rabbit checks the burrow first,
Before it digs and fills its thirst —
No source? A clear WP_Error returned,
The right code logged, the lesson learned.
Hop safe, dear site, your guard is earned! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding validation to guard against invalid source sites in the duplication process.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/salvage-pr1521-site-duplicator-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@superdav42

Copy link
Copy Markdown
Collaborator Author

MERGE_SUMMARY

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit daffcce into main Jun 24, 2026
11 checks passed
@superdav42

Copy link
Copy Markdown
Collaborator Author

Summary

Verification


aidevops.sh v3.22.0 plugin for OpenCode v1.17.9 with gpt-5.5 salvaged closed PR #1521 in a headless run.


Merged via PR #1538 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).

@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant