core/modules/contact/src/Controller/ContactController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/modules/contact/src/Controller/ContactController.php b/core/modules/contact/src/Controller/ContactController.php index 648a064..8813cd9 100644 --- a/core/modules/contact/src/Controller/ContactController.php +++ b/core/modules/contact/src/Controller/ContactController.php @@ -106,6 +106,7 @@ public function contactSitePage(ContactFormInterface $contact_form = NULL) { $form = $this->entityFormBuilder()->getForm($message); $form['#title'] = String::checkPlain($contact_form->label()); + $form['#cache']['contexts'][] = 'user.roles'; $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return $form; } @@ -141,6 +142,7 @@ public function contactPersonalPage(UserInterface $user) { $form = $this->entityFormBuilder()->getForm($message); $form['#title'] = $this->t('Contact @username', array('@username' => $user->getUsername())); + $form['#cache']['contexts'][] = 'user.roles'; return $form; } @@ -150,6 +152,9 @@ public function contactPersonalPage(UserInterface $user) { * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException */ protected function contactFloodControl() { + // Flood control is incompatible with page caching. + \Drupal::service('page_cache_kill_switch')->trigger(); + $limit = $this->config('contact.settings')->get('flood.limit'); $interval = $this->config('contact.settings')->get('flood.interval'); if (!$this->flood->isAllowed('contact', $limit, $interval)) {