Skip to content

[5.x] Fix static cache file paths for multisite setups #11724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/StaticCaching/Cachers/FileCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public function cachePage(Request $request, $content)

$content = $this->normalizeContent($content);

$path = $this->getFilePath($url);
$parsed = parse_url($url);
$domain = $parsed['scheme'].'://'.$parsed['host'];
$site = optional(Site::findByUrl($domain))->handle();
$path = $this->getFilePath($url, $site);

if (! $this->writer->write($path, $content, $this->config('lock_hold_length'))) {
return;
Expand All @@ -87,8 +90,10 @@ public function preventLoggingRewriteWarning()
public function getCachedPage(Request $request)
{
$url = $this->getUrl($request);

$path = $this->getFilePath($url);
$parsed = parse_url($url);
$domain = $parsed['scheme'].'://'.$parsed['host'];
$site = optional(Site::findByUrl($domain))->handle();
$path = $this->getFilePath($url, $site);

if ($this->logRewriteWarning && ! $this->isLongQueryStringPath($path)) {
Log::debug('Static cache loaded ['.$url.'] If you are seeing this, your server rewrite rules have not been set up correctly.');
Expand All @@ -100,8 +105,11 @@ public function getCachedPage(Request $request)
public function hasCachedPage(Request $request)
{
$url = $this->getUrl($request);
$parsed = parse_url($url);
$domain = $parsed['scheme'].'://'.$parsed['host'];
$site = optional(Site::findByUrl($domain))->handle();

return File::exists($this->getFilePath($url));
return File::exists($this->getFilePath($url, $site));
}

/**
Expand Down