Author: Kris.Wallsmith
Date: 2010-03-19 20:00:53 +0100 (Fri, 19 Mar 2010)
New Revision: 28625

Modified:
   branches/1.3/lib/filter/sfCacheFilter.class.php
   branches/1.3/test/functional/cacheTest.php
   
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
   
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml
   branches/1.4/lib/filter/sfCacheFilter.class.php
   branches/1.4/test/functional/cacheTest.php
   
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
   
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml
Log:
[1.3, 1.4] fixed broken reference to response in the cache filter when a page 
cache is found


Modified: branches/1.3/lib/filter/sfCacheFilter.class.php
===================================================================
--- branches/1.3/lib/filter/sfCacheFilter.class.php     2010-03-19 16:14:09 UTC 
(rev 28624)
+++ branches/1.3/lib/filter/sfCacheFilter.class.php     2010-03-19 19:00:53 UTC 
(rev 28625)
@@ -86,6 +86,9 @@
 
       if ($inCache)
       {
+        // update the local response reference with the one pulled from the 
cache
+        $this->response = $this->context->getResponse();
+
         // page is in cache, so no need to run execution filter
         return false;
       }
@@ -206,7 +209,7 @@
 
     // conditional GET support
     // never in debug mode
-    if ($this->response->hasHttpHeader('Last-Modified') && 
!sfConfig::get('sf_debug'))
+    if ($this->response->hasHttpHeader('Last-Modified') && 
(!sfConfig::get('sf_debug') || sfConfig::get('sf_test')))
     {
       $lastModified = $this->response->getHttpHeader('Last-Modified');
       if ($this->request->getHttpHeader('IF_MODIFIED_SINCE') == $lastModified)

Modified: branches/1.3/test/functional/cacheTest.php
===================================================================
--- branches/1.3/test/functional/cacheTest.php  2010-03-19 16:14:09 UTC (rev 
28624)
+++ branches/1.3/test/functional/cacheTest.php  2010-03-19 19:00:53 UTC (rev 
28625)
@@ -490,6 +490,17 @@
   ->with('view_cache')->isUriCached('cache/list?page=20', true)
 ;
 
+// check for 304 response
+sfConfig::set('LAST_MODIFIED', strtotime('2010-01-01'));
+$b->get('/cache/lastModifiedResponse')
+  ->with('response')->isStatusCode(200)
+;
+
+$b->setHttpHeader('If-Modified-Since', 
sfWebResponse::getDate(sfConfig::get('LAST_MODIFIED')))
+  ->get('/cache/lastModifiedResponse')
+  ->with('response')->isStatusCode(304)
+;
+
 // test with sfFileCache class (default)
 $b->launch();
 

Modified: 
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
===================================================================
--- 
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
    2010-03-19 16:14:09 UTC (rev 28624)
+++ 
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
    2010-03-19 19:00:53 UTC (rev 28625)
@@ -94,4 +94,10 @@
     $this->image = file_get_contents(dirname(__FILE__).'/../data/ok48.png');
     $this->setTemplate('image');
   }
+
+  public function executeLastModifiedResponse()
+  {
+    $this->getResponse()->setHttpHeader('Last-Modified', 
$this->getResponse()->getDate(sfConfig::get('LAST_MODIFIED')));
+    $this->setTemplate('action');
+  }
 }

Modified: 
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml
===================================================================
--- 
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml 
    2010-03-19 16:14:09 UTC (rev 28624)
+++ 
branches/1.3/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml 
    2010-03-19 19:00:53 UTC (rev 28625)
@@ -56,3 +56,7 @@
 
 list:
   enabled: true
+
+lastModifiedResponse:
+  enabled:     true
+  with_layout: true

Modified: branches/1.4/lib/filter/sfCacheFilter.class.php
===================================================================
--- branches/1.4/lib/filter/sfCacheFilter.class.php     2010-03-19 16:14:09 UTC 
(rev 28624)
+++ branches/1.4/lib/filter/sfCacheFilter.class.php     2010-03-19 19:00:53 UTC 
(rev 28625)
@@ -86,6 +86,9 @@
 
       if ($inCache)
       {
+        // update the local response reference with the one pulled from the 
cache
+        $this->response = $this->context->getResponse();
+
         // page is in cache, so no need to run execution filter
         return false;
       }
@@ -206,7 +209,7 @@
 
     // conditional GET support
     // never in debug mode
-    if ($this->response->hasHttpHeader('Last-Modified') && 
!sfConfig::get('sf_debug'))
+    if ($this->response->hasHttpHeader('Last-Modified') && 
(!sfConfig::get('sf_debug') || sfConfig::get('sf_test')))
     {
       $lastModified = $this->response->getHttpHeader('Last-Modified');
       if ($this->request->getHttpHeader('IF_MODIFIED_SINCE') == $lastModified)

Modified: branches/1.4/test/functional/cacheTest.php
===================================================================
--- branches/1.4/test/functional/cacheTest.php  2010-03-19 16:14:09 UTC (rev 
28624)
+++ branches/1.4/test/functional/cacheTest.php  2010-03-19 19:00:53 UTC (rev 
28625)
@@ -490,6 +490,17 @@
   ->with('view_cache')->isUriCached('cache/list?page=20', true)
 ;
 
+// check for 304 response
+sfConfig::set('LAST_MODIFIED', strtotime('2010-01-01'));
+$b->get('/cache/lastModifiedResponse')
+  ->with('response')->isStatusCode(200)
+;
+
+$b->setHttpHeader('If-Modified-Since', 
sfWebResponse::getDate(sfConfig::get('LAST_MODIFIED')))
+  ->get('/cache/lastModifiedResponse')
+  ->with('response')->isStatusCode(304)
+;
+
 // test with sfFileCache class (default)
 $b->launch();
 

Modified: 
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
===================================================================
--- 
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
    2010-03-19 16:14:09 UTC (rev 28624)
+++ 
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/actions/actions.class.php
    2010-03-19 19:00:53 UTC (rev 28625)
@@ -94,4 +94,10 @@
     $this->image = file_get_contents(dirname(__FILE__).'/../data/ok48.png');
     $this->setTemplate('image');
   }
+
+  public function executeLastModifiedResponse()
+  {
+    $this->getResponse()->setHttpHeader('Last-Modified', 
$this->getResponse()->getDate(sfConfig::get('LAST_MODIFIED')));
+    $this->setTemplate('action');
+  }
 }

Modified: 
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml
===================================================================
--- 
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml 
    2010-03-19 16:14:09 UTC (rev 28624)
+++ 
branches/1.4/test/functional/fixtures/apps/cache/modules/cache/config/cache.yml 
    2010-03-19 19:00:53 UTC (rev 28625)
@@ -56,3 +56,7 @@
 
 list:
   enabled: true
+
+lastModifiedResponse:
+  enabled:     true
+  with_layout: true

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to