comparison core/modules/big_pipe/src/Controller/BigPipeController.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
40 // access when either: 40 // access when either:
41 // - the no-JS cookie is already set: this indicates a redirect loop, since 41 // - the no-JS cookie is already set: this indicates a redirect loop, since
42 // the cookie was already set, yet the user is executing this controller; 42 // the cookie was already set, yet the user is executing this controller;
43 // - there is no session, in which case BigPipe is not enabled anyway, so it 43 // - there is no session, in which case BigPipe is not enabled anyway, so it
44 // is pointless to set this cookie. 44 // is pointless to set this cookie.
45 if ($request->cookies->has(BigPipeStrategy::NOJS_COOKIE) || $request->getSession() === NULL) { 45 if ($request->cookies->has(BigPipeStrategy::NOJS_COOKIE) || !$request->hasSession()) {
46 throw new AccessDeniedHttpException(); 46 throw new AccessDeniedHttpException();
47 } 47 }
48 48
49 if (!$request->query->has('destination')) { 49 if (!$request->query->has('destination')) {
50 throw new HttpException(400, 'The original location is missing.'); 50 throw new HttpException(400, 'The original location is missing.');
51 } 51 }
52 52
53 $response = new LocalRedirectResponse($request->query->get('destination')); 53 $response = new LocalRedirectResponse($request->query->get('destination'));
54 // Set cookie without httpOnly, so that JavaScript can delete it. 54 // Set cookie without httpOnly, so that JavaScript can delete it.
55 $response->headers->setCookie(new Cookie(BigPipeStrategy::NOJS_COOKIE, TRUE, 0, '/', NULL, FALSE, FALSE)); 55 $response->headers->setCookie(new Cookie(BigPipeStrategy::NOJS_COOKIE, TRUE, 0, '/', NULL, FALSE, FALSE, FALSE, NULL));
56 $response->addCacheableDependency((new CacheableMetadata())->addCacheContexts(['cookies:' . BigPipeStrategy::NOJS_COOKIE, 'session.exists'])); 56 $response->addCacheableDependency((new CacheableMetadata())->addCacheContexts(['cookies:' . BigPipeStrategy::NOJS_COOKIE, 'session.exists']));
57 return $response; 57 return $response;
58 } 58 }
59 59
60 } 60 }