From ee16772443dc6bf0154ac72ca6c10f7cd850c39e Mon Sep 17 00:00:00 2001 From: Damien Pobel Date: Wed, 20 Mar 2013 15:41:06 +0100 Subject: [PATCH] Fix EZP-20509: Cache issues when creating content --- Controller/DemoController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Controller/DemoController.php b/Controller/DemoController.php index 539e1ee..4aad0ff 100644 --- a/Controller/DemoController.php +++ b/Controller/DemoController.php @@ -31,8 +31,8 @@ public function topMenuAction( $locationId, array $excludeContentTypes = array() { $response = new Response; $response->setPublic(); - $response->setMaxAge( 60 ); - $location = $this->getRepository()->getLocationService()->loadLocation( $locationId ); + $response->setSharedMaxAge( 86400 ); + $response->headers->set( 'X-Location-Id', $locationId ); $excludeCriterion = array(); if ( !empty( $excludeContentTypes ) ) @@ -46,7 +46,6 @@ public function topMenuAction( $locationId, array $excludeContentTypes = array() } } $criteria = array( - new Criterion\Subtree( $location->pathString ), new Criterion\ParentLocationId( $locationId ), new Criterion\Visibility( Criterion\Visibility::VISIBLE ) ); @@ -96,9 +95,12 @@ public function topMenuAction( $locationId, array $excludeContentTypes = array() */ public function latestContentAction( $pathString, $contentTypeIdentifier, $limit, array $excludeLocations = array() ) { + $tmp = explode( '/', trim( $pathString, '/' ) ); + $locationId = end( $tmp ); $response = new Response; $response->setPublic(); - $response->setMaxAge( 60 ); + $response->setSharedMaxAge( 86400 ); + $response->headers->set( 'X-Location-Id', $locationId ); $contentType = $this->getRepository()->getContentTypeService()->loadContentTypeByIdentifier( $contentTypeIdentifier ); @@ -146,7 +148,8 @@ public function footerAction( $locationId ) { $response = new Response; $response->setPublic(); - $response->setMaxAge( 60 ); + $response->setSharedMaxAge( 86400 ); + $response->headers->set( 'X-Location-Id', $locationId ); $location = $this->getRepository()->getLocationService()->loadLocation( $locationId ); $content = $this->getRepository()->getContentService()->loadContent( $location->contentId );