Skip to content

GH#834: fix site-duplicator review-bot findings from PR #825#850

Merged
superdav42 merged 1 commit intomainfrom
feature/auto-20260414-092949
Apr 14, 2026
Merged

GH#834: fix site-duplicator review-bot findings from PR #825#850
superdav42 merged 1 commit intomainfrom
feature/auto-20260414-092949

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

Summary

Address three unresolved CodeRabbit findings from PR #825.

Fix 1 — Don't mutate $args->from_site_id after copy_data()

copy_data() and copy_files() had already run with the original $args->from_site_id when the wu_template_id meta override was applied. Overwriting the property in place meant copy_users() and any downstream consumers operated on a different source site than the data that was actually cloned, creating an inconsistent clone. The resolved template ID is now kept in a separate $template_site_id variable used only for the post-copy backfill, kit-integrity check, and wu_duplicate_site action payload.

Fix 2 — Apply URL rewrite to backfilled postmeta rows

backfill_postmeta() inserts rows after MUCD_Data::copy_data() has completed its db_update_data() pass. Those backfilled rows therefore contain raw template-site URLs (e.g. _menu_item_url custom links, _elementor_* JSON blobs). A new rewrite_backfilled_postmeta_urls() method mirrors MUCD's two-pass approach (plain URL and JSON-escaped \/ variant) on the target's postmeta table, correcting those references. The method is safe to call after MUCD's own rewrite because already-rewritten rows no longer contain the source URL, making REPLACE() a no-op for them.

Fix 3 — Tighten test_wu_duplicate_site_action_includes_from_site_id

The if ( ! is_wp_error($result)) guard caused the test to silently pass (skipping every assertion about the wu_duplicate_site action payload) whenever duplicate_site() returned a WP_Error. Replaced with an explicit $this->fail() call that surfaces the error message.

Files Changed

  • EDIT: inc/helpers/class-site-duplicator.php — Fix 1 + Fix 2 + new rewrite_backfilled_postmeta_urls() method
  • EDIT: tests/WP_Ultimo/Helpers/Site_Duplicator_Test.php — Fix 3

Runtime Testing

PHPStan level 0: clean (No errors). PHP syntax: clean. PHPCS: project configuration has pre-existing unresolved sniff-name errors that prevent the full WP ruleset from running — not introduced by this PR.

Resolves #834


aidevops.sh v3.8.24 plugin for OpenCode v1.4.3 with claude-sonnet-4-6 spent 7m and 25,232 tokens on this as a headless worker.

@superdav42
Copy link
Copy Markdown
Collaborator Author

Completion Summary

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 19 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 19 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 416a6289-23a9-46cb-ae14-aeeee517a8d4

📥 Commits

Reviewing files that changed from the base of the PR and between 002b9f9 and e067cf7.

📒 Files selected for processing (1)
  • inc/helpers/class-site-duplicator.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260414-092949

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 and usage tips.

- Replace in-place mutation of $args->from_site_id with a separate
  $template_site_id variable so copy_users() and any other downstream
  consumers retain a consistent source reference after copy_data() has
  already run with the original site ID.

- Add rewrite_backfilled_postmeta_urls() that applies the same
  source→target URL replacement MUCD's db_update_data() does, but
  scoped to the postmeta table. backfill_postmeta() inserts rows after
  MUCD's rewrite pass; without this step, _menu_item_url custom links
  and _elementor_* JSON would retain template-site domains.

- Tighten test_wu_duplicate_site_action_includes_from_site_id: fail
  explicitly with the WP_Error message instead of silently skipping
  all assertions when duplicate_site() returns an error.

Resolves #834
@superdav42 superdav42 force-pushed the feature/auto-20260414-092949 branch from 1bf6db3 to e067cf7 Compare April 14, 2026 15:39
@superdav42 superdav42 merged commit 0584d52 into main Apr 14, 2026
4 of 6 checks passed
@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

@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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Performance Test Results

Performance test results for 447a66f are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 41 37.80 MB 836.50 ms 152.00 ms 1033.00 ms 1944.00 ms (-44.00 ms / -2% ) 1839.35 ms (-51.45 ms / -3% ) 87.65 ms
1 56 49.02 MB 933.50 ms (-26.00 ms / -3% ) 141.50 ms 1073.00 ms (-29.50 ms / -3% ) 2064.00 ms 1989.65 ms 76.05 ms (-2.10 ms / -3% )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review followup: PR #825 — GH#820: backfill postmeta for nav_menu_item, attachment, and Elementor posts on site clone

1 participant