cms
cms copied to clipboard
[5.x] Static caching file path fallback
Statamic\StaticCaching\Invalidate sometimes throws errors like:
ErrorException: Trying to access array offset on value of type bool in /vendor/statamic/cms/src/StaticCaching/Cachers/FileCacher.php:163
This is caused by a "malformed url" like //?phpinfo=1 which is saved in the cached urls list. When invalidating the url can't be parsed by parse_url() as this function returns false when it's not a valid url: https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues
When invalidating
How are you invalidating //?phpinfo=1?
That happens automatically when something changes according the invalidation rules in config/statamic/static_caching.php with:
'urls' => [
'/*'
]
I can't reproduce an error. Could you provide a sample repo with this problem happening?
I'll provide more info shortly. Need to find some time :)
I'm marking this PR as a draft in the meantime. When you're able to provide replication steps, feel free to mark it "ready for review" again and we can take another look.
Alright, there we go; steps to reproduce this:
statamic new statamictestSTATAMIC_STATIC_CACHING_STRATEGY=fullin the.env- In
config/statamic/static_caching.php:
'invalidation' => [
'class' => null,
'rules' => [
'collections' => [
'pages' => [
'urls' => [
'/*'
]
],
]
],
],
- Go to http://statamictest.test//?phpinfo=1, yeah this is not something I would go to but bots try crazy things
- Change the page: http://statamictest.test/cp/collections/pages/entries/home and you'll get the error after the save:
Thanks! 🚀