From a8dca3908e3c1294728acabcbdacdadfbbe0957d Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 15 Dec 2008 01:30:41 +0000 Subject: [PATCH] Static caching merges from dnc branch git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@68900 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/HTTP.php | 9 ++++++++- core/Requirements.php | 3 +++ core/model/DataObject.php | 9 +++++++++ core/model/RedirectorPage.php | 8 +++++++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/HTTP.php b/core/HTTP.php index f48f5b96e..310d907a9 100644 --- a/core/HTTP.php +++ b/core/HTTP.php @@ -342,7 +342,7 @@ class HTTP { // Now that we've generated them, either output them or attach them to the HTTPResponse as appropriate foreach($responseHeaders as $k => $v) { if($body) $body->addHeader($k, $v); - else header("$k: $v"); + else if(!headers_sent()) header("$k: $v"); } } @@ -355,6 +355,13 @@ class HTTP { static function gmt_date($timestamp) { return gmdate('D, d M Y H:i:s', $timestamp) . ' GMT'; } + + /* + * Return static variable cache_age in second + */ + static function get_cache_age() { + return self::$cache_age; + } } diff --git a/core/Requirements.php b/core/Requirements.php index 476560598..b59eed99b 100644 --- a/core/Requirements.php +++ b/core/Requirements.php @@ -479,12 +479,14 @@ class Requirements_Backend { $this->disabled['css'] = $this->css; $this->disabled['customScript'] = $this->customScript; $this->disabled['customCSS'] = $this->customCSS; + Requirements::$disabled['customHeadTags'] = Requirements::$customHeadTags; $this->javascript = array(); $this->css = array(); $this->customScript = array(); $this->customCSS = array(); $this->customHeadTags = array(); + Requirements::$customHeadTags = ""; } } @@ -511,6 +513,7 @@ class Requirements_Backend { $this->css = $this->disabled['css']; $this->customScript = $this->disabled['customScript']; $this->customCSS = $this->disabled['customCSS']; + Requirements::$customHeadTags = Requirements::$disabled['customHeadTags']; } /** diff --git a/core/model/DataObject.php b/core/model/DataObject.php index b3945b032..6e5b86840 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -2332,6 +2332,15 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP $this->componentCache = array(); } + static function flush_and_destroy_cache() { + if(self::$cache_get_one) foreach(self::$cache_get_one as $class => $items) { + if(is_array($items)) foreach($items as $item) { + if($item) $item->destroy(); + } + } + self::$cache_get_one = array(); + } + /** * Does the hard work for get_one() * diff --git a/core/model/RedirectorPage.php b/core/model/RedirectorPage.php index 1d132bb2a..1a8df959b 100755 --- a/core/model/RedirectorPage.php +++ b/core/model/RedirectorPage.php @@ -140,6 +140,12 @@ class RedirectorPage extends Page { return $fields; } + + function subPagesToCache() { + $urls = parent::subPagesToCache(); + $urls[] = $this->URLSegment . '/'; + return $urls; + } } /** @@ -167,4 +173,4 @@ class RedirectorPage_Controller extends Page_Controller { ); } } -?> \ No newline at end of file +?>