Skip to content
Snippets Groups Projects

Issue #2430335 Browser language detection is not cache aware

Open Issue #2430335 Browser language detection is not cache aware
7 unresolved threads
7 unresolved threads

Browser language detection is not cache aware

Closes #2430335

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
6 use Drupal\Core\Cache\CacheableResponseInterface;
7 use Drupal\Core\PageCache\ResponsePolicyInterface;
8 use Symfony\Component\HttpFoundation\Request;
9 use Symfony\Component\HttpFoundation\Response;
10
11 /**
12 * A policy adding vary header to response.
13 */
14 class Vary implements ResponsePolicyInterface {
15
16 /**
17 * Array of Vary: headers to add to response.
18 *
19 * @var array
20 */
21 protected $vary = [];
  • 11 /**
    12 * A policy adding vary header to response.
    13 */
    14 class Vary implements ResponsePolicyInterface {
    15
    16 /**
    17 * Array of Vary: headers to add to response.
    18 *
    19 * @var array
    20 */
    21 protected $vary = [];
    22
    23 /**
    24 * Add vary header.
    25 */
    26 public function add($header) {
  • 20 */
    21 protected $vary = [];
    22
    23 /**
    24 * Add vary header.
    25 */
    26 public function add($header) {
    27 if (!in_array($header, $this->vary)) {
    28 $this->vary[] = $header;
    29 }
    30 }
    31
    32 /**
    33 * {@inheritdoc}
    34 */
    35 public function check(Response $response, Request $request) {
  • 31 /**
    32 * {@inheritdoc}
    33 */
    34 protected function setUp(): void {
    35 parent::setUp();
    36
    37 $this->config('system.site')
    38 ->set('name', 'Drupal')
    39 ->set('page.front', '/test-page')
    40 ->save();
    41 }
    42
    43 /**
    44 * Tests that custom vary header cached.
    45 */
    46 public function testPageCacheWithVary() {
  • 37 public static function create(ContainerInterface $container) {
    38 return new static(
    39 $container->get('page_cache_vary')
    40 );
    41 }
    42
    43 /**
    44 * Page that displays content that depends on custom request header.
    45 *
    46 * @param \Symfony\Component\HttpFoundation\Request $request
    47 * The request.
    48 *
    49 * @return array
    50 * Renderable array expected by renderer service.
    51 */
    52 public function pageVary(Request $request) {
  • sleitner added 18 commits

    added 18 commits

    • 774eba14...bc0b5a19 - 17 commits from branch project:11.x
    • 5df55436 - Merge branch drupal:11.x into 2430335-browser-language-detection

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    • 7a0b226f - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    • b6d1d69f - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    • 9e2f8099 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    • 0f9aee77 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    Compare with previous version

  • 48 48 protected $responsePolicy;
    49 49
    50 50 /**
    51 * The cache ID for the (master) request.
    51 * The cache IDs for the (main) request.
    52 52 *
    53 * @var string
    53 * @var string[]
    54 54 */
    55 protected $cid;
    55 protected $cids;
  • 50 50 /**
    51 * The cache ID for the (master) request.
    51 * The cache IDs for the (main) request.
    52 52 *
    53 * @var string
    53 * @var string[]
    54 54 */
    55 protected $cid;
    55 protected $cids;
    56
    57 /**
    58 * The request used for generating the cache ID.
    59 *
    60 * @var \Symfony\Component\HttpFoundation\Request
    61 */
    62 protected $requestUsedForCid;
  • sleitner added 1 commit

    added 1 commit

    • 2e982643 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • sleitner added 1 commit

    added 1 commit

    Compare with previous version

  • Please register or sign in to reply
    Loading