Skip to content

GH#2131: fix: guard srcset mapping after blog switch - #2153

Merged
superdav42 merged 1 commit into
mainfrom
feature/auto-20261125-115314-gh2131
Nov 25, 2026
Merged

superdav42 merged 1 commit into
mainfrom
feature/auto-20261125-115314-gh2131

Conversation

@superdav42

@superdav42 superdav42 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Prevent the request host's domain mapping from rewriting srcset URLs while rendering a different switched blog. Other mapped URL filters already route through mangle_url, which has target-site guards.

Files Changed

inc/class-domain-mapping.php

Runtime Testing

  • Risk level: Medium
  • Verification: self-assessed — vendor/bin/phpcs inc/class-domain-mapping.php; vendor/bin/phpstan analyse inc/class-domain-mapping.php --no-progress; php -l inc/class-domain-mapping.php; git diff --check origin/main...HEAD. Runtime multisite verification was self-assessed because the worktree has no WordPress dev install or WordPress test suite.

Resolves #2131


aidevops.sh v3.39.189 plugin for OpenCode v1.19.5 with gpt-5.6-sol spent 3m and 70,126 tokens on this as a headless worker.

Summary by CodeRabbit

  • Bug Fixes
    • Srcset URLs now remain unchanged when the current blog doesn’t match the mapping’s blog.

@superdav42 superdav42 added the origin:worker Auto-created by pulse labelless backfill (t2112) label Nov 25, 2026
@superdav42

superdav42 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Prevent the request host's domain mapping from rewriting srcset URLs while rendering a different switched blog. Other mapped URL filters already route through mangle_url, which has target-site guards.
  • Issue: Domain mapping fix_srcset applies the request's mapped domain to other sites' images after switch_to_blog #2131
  • Files changed: inc/class-domain-mapping.php
  • Testing: vendor/bin/phpcs inc/class-domain-mapping.php; vendor/bin/phpstan analyse inc/class-domain-mapping.php --no-progress; php -l inc/class-domain-mapping.php; git diff --check origin/main...HEAD. Runtime multisite verification was self-assessed because the worktree has no WordPress dev install or WordPress test suite.
  • Key decisions: none

aidevops.sh v3.39.189 plugin for OpenCode v1.19.5 with gpt-5.6-sol spent 3m and 70,126 tokens on this as a headless worker.


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

Routing feedback

  • Route: standard; 1 attempt, 23 LLM requests, 0 capability escalations, 1 same-tier fallback.
  • Population: headless; 0 objective outcomes.
  • Usage: 1,351,619 tokens; $0.9081 estimated cost.
  • Recommendation: No routing change is recommended from this sample.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

fix_srcset now returns source URLs unchanged when the current blog ID differs from the current mapping’s blog ID. The existing checks for an empty mapping and a missing site remain.

Changes: Srcset mapping

Layer / File(s) Summary
Guard srcset remapping
inc/class-domain-mapping.php
fix_srcset returns the original sources when the current blog ID differs from the mapping’s blog ID. The existing empty-mapping and missing-site checks remain.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: marcusquinn

Merge Risk: Minimal · up to ac232

The change stops srcset URLs from being rewritten to the request host's mapped domain after switch_to_blog(). Images on the mapped site keep using the mapped domain. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a guard on srcset domain mapping after a blog switch, which matches the fix to fix_srcset() in inc/class-domain-mapping.php. It also carries the issue reference GH#213…
Linked Issues check Passed Issue #2131 requires that fix_srcset() return $sources unchanged unless the mapping's blog ID matches get_current_blog_id(), as mangle_url() does. The change summary for inc/class-domain-mapping.php s…
Out of Scope Changes check Passed The PR changes one file, inc/class-domain-mapping.php, with +5/-1 lines according to the change summary. The change adds the blog-ID guard in fix_srcset(), which the linked issue names as the required…
Full details: Title check

Explanation

The title names the main change: a guard on srcset domain mapping after a blog switch, which matches the fix to fix_srcset() in inc/class-domain-mapping.php. It also carries the issue reference GH#2131 and the conventional 'fix:' prefix. The title is 52 characters, within a normal length.

Full details: Linked Issues check

Explanation

Issue #2131 requires that fix_srcset() return $sources unchanged unless the mapping's blog ID matches get_current_blog_id(), as mangle_url() does. The change summary for inc/class-domain-mapping.php states that fix_srcset() now returns the original sources when the current blog ID differs from the current mapping's blog ID, in addition to the existing empty-mapping and no-site checks. This meets the core fix. The reviewed file read was truncated before fix_srcset(), so the code hunk was not read directly; the verdict relies on the change summary. The issue also asks to check other filters in register_mapped_filters(). The visible registrations route through mangle_url (site_url, home_url, option_siteurl, option_home, theme_file_uri, plugins_url, and others), which has the guard. The body of mangle_network_url() was not visible, so that one filter is not independently confirmed. No automated test was added. The issue's verification steps are runtime multisite checks, and the PR reports that runtime verification was not performed.

Full details: Out of Scope Changes check

Explanation

The PR changes one file, inc/class-domain-mapping.php, with +5/-1 lines according to the change summary. The change adds the blog-ID guard in fix_srcset(), which the linked issue names as the required scope. No unrelated changes were reported. The diff hunk itself was not read because of the evidence truncation, so this verdict rests on the change summary and PR file list.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 253e01d5-761c-4de9-bded-7f1bbf307380
Commits

Reviewing files that changed from the base of the PR and between f320fd5 and ac232b0.

Files selected for processing: 1

  • inc/class-domain-mapping.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@ultimate-multisite ultimate-multisite Bot added the status:in-review Non-draft PR ready for review/merge label Nov 25, 2026
@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 8b996de into main Nov 25, 2026
15 checks passed
@superdav42 superdav42 added status:done Task is complete and removed status:in-review Non-draft PR ready for review/merge labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:worker Auto-created by pulse labelless backfill (t2112) status:done Task is complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain mapping fix_srcset applies the request's mapped domain to other sites' images after switch_to_blog

1 participant