Commit 0018ea09 authored by mglaman's avatar mglaman Committed by bojanz

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

parent 6a59dc08
......@@ -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);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment