[BUGFIX] Do not cache content with different status code than 200 82/58582/3
authorMarkus Klein <markus.klein@typo3.org>
Fri, 5 Oct 2018 08:57:24 +0000 (10:57 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 10 Oct 2018 10:45:57 +0000 (12:45 +0200)
Resolves: #83755
Releases: master, 8.7, 7.6
Change-Id: I6e13133f221137c63283ec1575fc405a38668b1a
Reviewed-on: https://review.typo3.org/58582
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Johannes Kasberger <johannes.kasberger@reelworx.at>
Tested-by: Johannes Kasberger <johannes.kasberger@reelworx.at>
Reviewed-by: Tomas Norre Mikkelsen <tomasnorre@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/frontend/Classes/Http/RequestHandler.php

index 66f6bb8..ae7e3c6 100644 (file)
@@ -228,6 +228,11 @@ class RequestHandler implements RequestHandlerInterface, PsrRequestHandlerInterf
 
         if ($isOutputting) {
             $response->getBody()->write($controller->content);
+            // if any code set a response code that is not 200 clear the cache's content
+            // if we fail to do so we would deliver cache content with a wrong header, which causes big mess.
+            if (http_response_code() !== 200 || $response->getStatusCode() !== 200) {
+                $controller->clearPageCacheContent();
+            }
         }
 
         return $isOutputting ? $response : new NullResponse();