Commit 0018ea09 authored by Matt Glaman's avatar Matt Glaman Committed by Bojan Živanović
Browse files

Issue #2838472 by mglaman: Do not allow NeedsRedirectException to be cached (#585)

parent 6a59dc08
Loading
Loading
Loading
Loading
+6 −1
Changes for src/Response/NeedsRedirectException.php: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\commerce\Response;

use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Form\EnforcedResponseException;
use Drupal\Core\Routing\TrustedRedirectResponse;

@@ -28,7 +29,11 @@ class NeedsRedirectException extends EnforcedResponseException {
      throw new \InvalidArgumentException('Invalid URL provided.');
    }

    parent::__construct(new TrustedRedirectResponse($url, $status_code, $headers));
    $response = new TrustedRedirectResponse($url, $status_code, $headers);
    $cacheable_metadata = new CacheableMetadata();
    $cacheable_metadata->setCacheMaxAge(0);
    $response->addCacheableDependency($cacheable_metadata);
    parent::__construct($response);
  }

}