Skip to content

Fix: use home_url() instead of site_url() in get_current_url_supercache_dir#1024

Draft
kraftbj wants to merge 5 commits intotrunkfrom
cherry-pick/613-home-url-supercache-dir
Draft

Fix: use home_url() instead of site_url() in get_current_url_supercache_dir#1024
kraftbj wants to merge 5 commits intotrunkfrom
cherry-pick/613-home-url-supercache-dir

Conversation

@kraftbj
Copy link
Copy Markdown
Contributor

@kraftbj kraftbj commented Apr 7, 2026

Summary

  • Replace site_url() with home_url() in get_current_url_supercache_dir(), since permalinks are relative to the home URL, not the site URL (these differ when WordPress is installed in a subdirectory).
  • Use wp_parse_url( $permalink, PHP_URL_PATH ) to extract the URI path instead of string-replacing with $wp_cache_home_path, which doesn't work reliably in multisite installations.
  • Add strict type checking to in_array() call.

Originally proposed by @stodorovic in #613.

See #613

Test plan

  • Verify cache directory resolution on a standard single-site install.
  • Verify cache directory resolution on a multisite install.
  • Verify cache directory resolution when WordPress is installed in a subdirectory (site URL differs from home URL).
  • Confirm get_current_url_supercache_dir() returns the correct path for individual post IDs.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts supercache directory resolution to use the WordPress “home” URL and more robust URL parsing, improving correctness for subdirectory installs and multisite setups (see #613 / #613).

Changes:

  • Replaces site_url() with home_url() when deriving the permalink-relative cache path.
  • Uses wp_parse_url( $permalink, PHP_URL_PATH ) instead of string replacement against $wp_cache_home_path.
  • Enables strict comparison for the in_array() check against $cached_direct_pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kraftbj kraftbj force-pushed the cherry-pick/613-home-url-supercache-dir branch from 34da52d to 65fb755 Compare April 7, 2026 22:10
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.

3 participants