Skip to content

Fixed: search_source referrer duplicating the subdirectory on subdirectory installs - #325

Merged
Dan0sz merged 1 commit into
developfrom
fix_search_source
Sep 23, 2026
Merged

Dan0sz merged 1 commit into
developfrom
fix_search_source

Conversation

@Dan0sz

@Dan0sz Dan0sz commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Search::get_referrer() built the referrer as home_url( add_query_arg( null, null ) ). add_query_arg( null, null ) returns the current REQUEST_URI, which on a subdirectory install (site under e.g. /dev) already includes the subdirectory; home_url() then prepends the home path again, producing a doubled prefix like https://example.com/dev/dev/sample-page/?s=test.

Take the scheme and host from the configured home_url() and append the request path/query directly, so the subdirectory appears exactly once. Deriving the scheme from home_url() also keeps the referrer on https behind a reverse proxy, where is_ssl() may be unreliable.

Summary by CodeRabbit

  • Bug Fixes
    • Improved referrer URL handling for sites installed in subdirectories and sites behind reverse proxies.
    • Referrer values now remain empty when a host cannot be determined or the URL is invalid.

…ry installs

Search::get_referrer() built the referrer as home_url( add_query_arg( null, null ) ).
add_query_arg( null, null ) returns the current REQUEST_URI, which on a subdirectory
install (site under e.g. /dev) already includes the subdirectory; home_url() then
prepends the home path again, producing a doubled prefix like
https://example.com/dev/dev/sample-page/?s=test.

Take the scheme and host from the configured home_url() and append the request
path/query directly, so the subdirectory appears exactly once. Deriving the scheme
from home_url() also keeps the referrer on https behind a reverse proxy, where
is_ssl() may be unreliable.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4f77edd6-9b40-41f4-98f3-393608d0ddb9

📥 Commits

Reviewing files that changed from the base of the PR and between e4ac7b0 and 7f53523.

📒 Files selected for processing (1)
  • src/Integrations/Search.php

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

get_referrer() now combines URL components from home_url() with the current request URI. It returns an empty string when it cannot determine a host.

Changes

Referrer URL construction

Layer / File(s) Summary
Build the referrer URL
src/Integrations/Search.php
get_referrer() parses the scheme, host, and port from home_url(), with fallbacks to is_ssl() and HTTP_HOST. It adds the current request path and query. If no host is available, it returns an empty string. The method retains its escaping and empty-string fallback behavior.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 7f535

The referrer change has no identified issue requiring a fix before merge.

🚥 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 identifies the primary change: fixing duplicated subdirectory paths in the search referrer on subdirectory installs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Dan0sz
Dan0sz merged commit 76f55e5 into develop Sep 23, 2026
7 checks passed
@Dan0sz
Dan0sz deleted the fix_search_source branch September 23, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant