You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that the static:warm command isn't excluding URLs of sites that use a domain that's different from APP_URL.
It's important to note that this issue doesn't actually affect the statically cached pages. It only affects the URLs that are considered for warming by the static:warm command.
When calling the static:warm command, it will correctly exclude the /story/* URLs in the default gounity site. However, it will still warm all the URLs in the gomagazin site.
What's happening
The URLs that should be excluded from the static:warm command are rejected here:
The issue is that the baseUrl of the DefaultUrlExcluder class will resolve to the URL of the current request as per the getBaseUrl() method in the AbstractCacher class.
The $baseUrl will always be Site::current(), which is resolved from request()->getUri(). When running the static:warm command, request()->getUri() will resolve to the APP_URL and not the URL of the site that the URL that is about to be cached belongs to.
Bug description
I've noticed that the
static:warm
command isn't excluding URLs of sites that use a domain that's different fromAPP_URL
.It's important to note that this issue doesn't actually affect the statically cached pages. It only affects the URLs that are considered for warming by the
static:warm
command.Example
Consider the following setup:
config/statamic/sites.php
config/statamic/static_caching.php
.env
When calling the
static:warm
command, it will correctly exclude the/story/*
URLs in the defaultgounity
site. However, it will still warm all the URLs in thegomagazin
site.What's happening
The URLs that should be excluded from the
static:warm
command are rejected here:cms/src/Console/Commands/StaticWarm.php
Lines 170 to 172 in 024aad4
The issue is that the
baseUrl
of theDefaultUrlExcluder
class will resolve to the URL of the current request as per thegetBaseUrl()
method in theAbstractCacher
class.cms/src/StaticCaching/Cachers/AbstractCacher.php
Lines 49 to 62 in 024aad4
The
$baseUrl
will always beSite::current()
, which is resolved fromrequest()->getUri()
. When running thestatic:warm
command,request()->getUri()
will resolve to theAPP_URL
and not the URL of the site that the URL that is about to be cached belongs to.cms/src/Sites/Sites.php
Lines 72 to 77 in 024aad4
And this leads to the
isExcluded()
method returning false on any site that doesn't use theAPP_URL
as base.cms/src/StaticCaching/DefaultUrlExcluder.php
Lines 28 to 47 in 024aad4
Workaround
You can work around this issue by explicitly excluding absolute URLs.
How to reproduce
static:warm
commandLogs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
This issue sounds very similar to #7456.
The text was updated successfully, but these errors were encountered: