Skip to content

tgc.church#256: route mapped multisite queue jobs - #56

Merged
superdav42 merged 1 commit into
mainfrom
bugfix/gh256-fix-queue-worker-payload-routing-for-map
Aug 4, 2026
Merged

tgc.church#256: route mapped multisite queue jobs#56
superdav42 merged 1 commit into
mainfrom
bugfix/gh256-fix-queue-worker-payload-routing-for-map

Conversation

@superdav42

@superdav42 superdav42 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Prefer a uniquely owned active domain mapping when building switched-site queue payloads.
  • Fail closed when a canonical domain is actively mapped to another blog.
  • Emit one bounded diagnostic per unroutable site instead of repeatedly spawning mismatched executors.

Root cause

Full-network scans used each wp_blogs canonical domain for executor bootstrap. On domain-mapped sites, that hostname can resolve to a different blog, so the executor correctly rejected jobs with a payload-site mismatch and due Action Scheduler rows remained pending.

Verification

  • composer validate --strict
  • composer test:regression
  • php -l src/class-job-payload.php
  • php -l src/class-worker-process.php
  • php -l tests/regression.php
  • git diff --check

Deployment note

For superdav42/tgc.church#256. Keep the production-health issue open until this plugin commit is consumed by the Bedrock project, deployed, and the read-only Action Scheduler audit confirms the stale queues remain clear.


aidevops.sh v3.32.219 plugin for OpenCode v1.18.9 with gpt-5.6-sol spent 3h 35m and 731,130 tokens on this with the user in an interactive session.

Summary by CodeRabbit

  • Bug Fixes
    • Improved switched-site URL selection by preferring unique, active domain mappings.
    • Prevented URL generation from using a canonical domain when it is actively mapped to another site.
    • Unroutable jobs now remain pending and produce only one diagnostic per site.
  • Tests
    • Added regression coverage for domain-mapping conflicts, preferred URLs, and repeated unroutable job handling.

@superdav42 superdav42 added the origin:interactive Created by interactive user session label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds active domain-mapping resolution for switched-site payload URLs. It fails closed on canonical-domain conflicts. Worker scheduling now skips unroutable jobs and logs each affected site once. Regression fixtures cover mapping lookup, conflicts, and diagnostic deduplication.

Changes

Switched-site job routing

Layer / File(s) Summary
Domain mapping URL resolution
src/class-job-payload.php, tests/regression.php
Payload URLs use unique active mappings when available. Mapping tables and domains are validated. Canonical-domain conflicts return an empty URL. Regression fixtures and tests cover these cases.
Unroutable job scheduling
src/class-worker-process.php
schedule_timer() skips payloads with empty site_url, logs once per site, records the site, and leaves the job pending.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JobPayload
  participant DomainMappingDB
  participant WorkerProcess
  JobPayload->>DomainMappingDB: Query active domain mapping
  DomainMappingDB-->>JobPayload: Return mapped URL or conflict result
  JobPayload->>WorkerProcess: Provide payload with site_url
  WorkerProcess->>WorkerProcess: Skip scheduling when site_url is empty
  WorkerProcess-->>WorkerProcess: Log once per site and keep job pending
Loading
🚥 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 summarizes the main change: routing multisite queue jobs for mapped domains.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 bugfix/gh256-fix-queue-worker-payload-routing-for-map

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.2.6)

PHPStan was skipped because the config uses disallowed bootstrapFiles, bootstrapFile, or includes directives.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/class-job-payload.php`:
- Around line 205-280: Cache the domain-mapping table availability and resolved
routing outcome used by current_mapped_site_url() and
canonical_domain_is_mapped_elsewhere() per site during a rescan, so repeated
payloads avoid repeating table and mapping queries. Add a reset of these caches
at the start of each rescan, ensuring routing metadata repairs are observed by
the next scan while preserving existing URL and conflict behavior.
🪄 Autofix (Beta)

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: 4ff7f208-99d2-4d2c-9b9d-b44852ddf9d1

📥 Commits

Reviewing files that changed from the base of the PR and between 09ec0fd and 38be013.

📒 Files selected for processing (3)
  • src/class-job-payload.php
  • src/class-worker-process.php
  • tests/regression.php

Comment thread src/class-job-payload.php
@superdav42
superdav42 merged commit 8b4e599 into main Aug 4, 2026
1 check passed
@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session 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