[BUGFIX] Do not cache content with different status code than 200 80/58580/3
authorMarkus Klein <markus.klein@typo3.org>
Fri, 5 Oct 2018 08:32:02 +0000 (10:32 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Wed, 10 Oct 2018 18:41:56 +0000 (20:41 +0200)
Resolves: #83755
Releases: master, 8.7, 7.6
Change-Id: I6e13133f221137c63283ec1575fc405a38668b1a
Reviewed-on: https://review.typo3.org/58580
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/frontend/Classes/Http/RequestHandler.php

index ef299be..286b6c8 100644 (file)
@@ -285,6 +285,11 @@ class RequestHandler implements RequestHandlerInterface
         if (TYPO3_DLOG) {
             GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, ['_FLUSH' => true]);
         }
+        // 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) {
+            $this->controller->clearPageCacheContent();
+        }
         return $response;
     }