BUGFIX Bypass static caching through static-main.php when GET or POST parameters are set (regression from 2.3 API, fixes #5519, thanks ktauber) (from r103961)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112327 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-10-14 23:52:30 +00:00
parent 80f609ee41
commit 683cf79fe6

View File

@ -22,8 +22,15 @@ $cacheBaseDir = '../cache/'; // Should point to the same folder as FilesystemPub
$hostmapLocation = '../subsites/host-map.php';
$homepageMapLocation = '../assets/_homepage-map.php';
if ($cacheEnabled && empty($_COOKIE['bypassStaticCache'])) {
if (
$cacheEnabled
&& empty($_COOKIE['bypassStaticCache'])
// No GET params other than cache relevant config is passed (e.g. "?stage=Stage"),
// which would mean that we have to bypass the cache
&& count(array_diff(array_keys($_GET), array('url', 'cacheSubdir'))) == 0
// Request is not POST (which would have to be handled dynamically)
&& count($_POST) == 0
) {
// Define system paths (copied from Core.php)
if(!defined('BASE_PATH')) {
// Assuming that this file is sapphire/static-main.php we can then determine the base path
@ -75,6 +82,7 @@ if ($cacheEnabled && empty($_COOKIE['bypassStaticCache'])) {
// Find file by extension (either *.html or *.php)
$file = preg_replace('/[^a-zA-Z0-9\/\-_]/si', '-', $file);
if (file_exists($cacheBaseDir . $cacheDir . $file . '.html')) {
header('X-SilverStripe-Cache: hit at '.@date('r'));
echo file_get_contents($cacheBaseDir . $cacheDir . $file . '.html');