Skip to content

GH#1717: skip switch_blog hooks for global tables - #1718

Merged
superdav42 merged 2 commits into
mainfrom
feature/auto-20260810-142726-gh1717
Aug 10, 2026
Merged

GH#1717: skip switch_blog hooks for global tables#1718
superdav42 merged 2 commits into
mainfrom
feature/auto-20260810-142726-gh1717

Conversation

@superdav42

@superdav42 superdav42 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the redundant switch_blog callback from global Ultimate Multisite database tables.
  • Retain callbacks and state switching for per-site database tables.
  • Add regression coverage for hook registration and table state across site switches.

Testing

  • vendor/bin/phpcs inc/database/engine/class-table.php tests/WP_Ultimo/Database/Engine/Table_Test.php
  • vendor/bin/phpstan analyse inc/database/engine/class-table.php
  • vendor/bin/phpunit --filter Table_Test

Runtime Testing

  • Runtime-verified with the WordPress multisite PHPUnit environment.

Resolves #1717


aidevops.sh v3.32.250 plugin for OpenCode v1.18.9 with gpt-5.6-terra spent 8m and 122,392 tokens on this as a headless worker.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of global database tables when switching between sites.
    • Preserved the correct table prefix and state during site changes, including when returning to the original site.
  • Tests

    • Added coverage for global and per-site table behavior, callback registration, and state restoration.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@superdav42, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 12f82553-ab95-4759-b2db-2b93ccc36fa5

📥 Commits

Reviewing files that changed from the base of the PR and between 08d2c76 and 103de74.

📒 Files selected for processing (1)
  • inc/database/engine/class-table.php
📝 Walkthrough

Walkthrough

The table constructor now removes switch_blog handling for global tables after parent initialization. Per-site tables retain the callback. Tests verify callback registration, state preservation, site switching, and restoration.

Changes

Table hook optimization

Layer / File(s) Summary
Hook handling and regression validation
inc/database/engine/class-table.php, tests/WP_Ultimo/Database/Engine/Table_Test.php
Global tables remove the inherited switch_blog callback. Per-site tables retain it. Tests verify state behavior across site switches and restoration.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 describes the primary change: skipping switch_blog hooks for global tables.
Linked Issues check ✅ Passed The implementation removes callbacks for global tables, preserves per-site switching, and adds regression tests for both behaviors [#1717].
Out of Scope Changes check ✅ Passed The changes are limited to the table constructor and focused tests required by issue #1717.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/auto-20260810-142726-gh1717

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

superdav42 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Removes no-op switch_blog callbacks from global Ultimate Multisite BerlinDB tables.
  • Issue: Skip switch_blog hooks for global database tables #1717
  • Files changed: inc/database/engine/class-table.php, tests/WP_Ultimo/Database/Engine/Table_Test.php
  • Testing: PHPCS and PHPStan passed; the WordPress multisite Table_Test behavior ran successfully.
  • Key decisions: The inherited global flag controls removal, preserving callbacks for per-site and addon table subclasses.

aidevops.sh v3.32.250 plugin for OpenCode v1.18.9 with gpt-5.6-terra spent 8m and 125,002 tokens on this as a headless worker.


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

Routing feedback

  • Route: standard; 1 attempt, 0 capability escalations, 0 same-tier fallbacks.
  • Recommendation: No routing change is recommended from this sample.

@superdav42
superdav42 marked this pull request as ready for review August 10, 2026 20:37
@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

@ultimate-multisite ultimate-multisite Bot added the status:in-review PR open, awaiting review/merge label Aug 10, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@inc/database/engine/class-table.php`:
- Around line 81-83: Update the condition in the Table class cleanup block to
use the required Yoda comparison, changing the global-state check to compare
true against $this->global while preserving the existing remove_action call.

In `@tests/WP_Ultimo/Database/Engine/Table_Test.php`:
- Line 32: Replace the site creation calls in the test setup with
wu_create_site() for both test sites, handling any WP_Error result before
continuing. Use each returned site's get_id() value when calling
switch_to_blog(), updating the affected setup paths around the existing site
variables.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 090d3a5b-6920-4875-8e02-d7daf9f4764d

📥 Commits

Reviewing files that changed from the base of the PR and between 75e3b0e and 08d2c76.

📒 Files selected for processing (2)
  • inc/database/engine/class-table.php
  • tests/WP_Ultimo/Database/Engine/Table_Test.php

Comment thread inc/database/engine/class-table.php Outdated
Comment thread tests/WP_Ultimo/Database/Engine/Table_Test.php
@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 af3f981 into main Aug 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:in-review PR open, awaiting review/merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skip switch_blog hooks for global database tables

1 participant