diff --git a/core/modules/aggregator/src/Controller/AggregatorController.php b/core/modules/aggregator/src/Controller/AggregatorController.php index b49f3f5..b85ca2c 100644 --- a/core/modules/aggregator/src/Controller/AggregatorController.php +++ b/core/modules/aggregator/src/Controller/AggregatorController.php @@ -173,6 +173,10 @@ public function adminOverview() { public function pageLast() { $items = $this->entityManager()->getStorage('aggregator_item')->loadAll(20); $build = $this->buildPageList($items); + + $config = $this->config('system.site'); + $build['#cache']['tags'] = $config->getCacheTags(); + $build['#attached']['feed'][] = array('aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator')); return $build; } diff --git a/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php index b903250..fe27860 100644 --- a/core/modules/comment/src/CommentViewBuilder.php +++ b/core/modules/comment/src/CommentViewBuilder.php @@ -10,6 +10,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Access\CsrfTokenGenerator; +use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; @@ -154,7 +155,9 @@ public function buildComponents(array &$build, array $entities, array $displays, } $account = comment_prepare_author($entity); - if (\Drupal::config('user.settings')->get('signatures') && $account->getSignature()) { + $config = \Drupal::config('user.settings'); + $build['#cache']['tags'] = Cache::mergeTags(isset($build['#cache']['tags']) ? $build['#cache']['tags'] : [], $config->getCacheTags()); + if ($config->get('signatures') && $account->getSignature()) { $build[$id]['signature'] = array( '#type' => 'processed_text', '#text' => $account->getSignature(), diff --git a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php index 1a97e1b..fc4501d 100644 --- a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php @@ -108,6 +108,7 @@ public function testCacheTags() { 'comment_view', 'comment:' . $comment->id(), 'config:filter.format.plain_text', + 'config:user.settings', 'user_view', 'user:2', ); diff --git a/core/modules/contact/src/Controller/ContactController.php b/core/modules/contact/src/Controller/ContactController.php index cffbf5a..c821e2c 100644 --- a/core/modules/contact/src/Controller/ContactController.php +++ b/core/modules/contact/src/Controller/ContactController.php @@ -7,6 +7,7 @@ namespace Drupal\contact\Controller; +use Drupal\Core\Cache\Cache; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Flood\FloodInterface; @@ -77,12 +78,13 @@ public function contactSitePage(ContactFormInterface $contact_form = NULL) { if (!$this->currentUser()->hasPermission('administer contact forms')) { $this->contactFloodControl(); } + $config = $this->config('contact.settings'); // Use the default form if no form has been passed. if (empty($contact_form)) { $contact_form = $this->entityManager() ->getStorage('contact_form') - ->load($this->config('contact.settings')->get('default_form')); + ->load($config->get('default_form')); // If there are no forms, do not display the form. if (empty($contact_form)) { if ($this->currentUser()->hasPermission('administer contact forms')) { @@ -104,6 +106,7 @@ public function contactSitePage(ContactFormInterface $contact_form = NULL) { $form = $this->entityFormBuilder()->getForm($message); $form['#title'] = String::checkPlain($contact_form->label()); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return $form; } diff --git a/core/modules/forum/src/Controller/ForumController.php b/core/modules/forum/src/Controller/ForumController.php index 951e254..18d7325 100644 --- a/core/modules/forum/src/Controller/ForumController.php +++ b/core/modules/forum/src/Controller/ForumController.php @@ -7,6 +7,7 @@ namespace Drupal\forum\Controller; +use Drupal\Core\Cache\Cache; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityAccessControlHandlerInterface; use Drupal\Core\Entity\EntityStorageInterface; @@ -190,6 +191,7 @@ protected function build($forums, TermInterface $term, $topics = array(), $paren if (empty($term->forum_container->value)) { $build['#attached']['feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->getName()); } + $build['#cache']['tags'] = Cache::mergeTags(isset($build['#cache']['tags']) ? $build['#cache']['tags'] : [], $config->getCacheTags()); return [ 'action' => $this->buildActionLinks($config->get('vocabulary'), $term), diff --git a/core/modules/search/src/Controller/SearchController.php b/core/modules/search/src/Controller/SearchController.php index 4e79f79..6bba26a 100644 --- a/core/modules/search/src/Controller/SearchController.php +++ b/core/modules/search/src/Controller/SearchController.php @@ -7,6 +7,7 @@ namespace Drupal\search\Controller; +use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Controller\ControllerBase; use Drupal\search\SearchPageInterface; @@ -89,7 +90,9 @@ public function view(Request $request, SearchPageInterface $entity) { if ($request->query->has('keys')) { if ($plugin->isSearchExecutable()) { // Log the search. - if ($this->config('search.settings')->get('logging')) { + $config = $this->config('search.settings'); + $build['#cache']['tags'] = Cache::mergeTags(isset($build['#cache']['tags']) ? $build['#cache']['tags'] : [], $config->getCacheTags()); + if ($config->get('logging')) { $this->logger->notice('Searched %type for %keys.', array('%keys' => $keys, '%type' => $entity->label())); } diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php index 3fc3e34..c9d11eb 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -93,6 +93,7 @@ function testPageCacheTags() { 'config:system.menu.tools', 'config:system.menu.footer', 'config:system.menu.main', + 'config:system.site', )); // Full node page 2. @@ -124,6 +125,7 @@ function testPageCacheTags() { 'config:system.menu.tools', 'config:system.menu.footer', 'config:system.menu.main', + 'config:system.site', )); } diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index 7ed3cbd..3bb8779 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -74,6 +74,7 @@ public function form(array $form, FormStateInterface $form_state) { $account = $this->entity; $user = $this->currentUser(); $config = \Drupal::config('user.settings'); + $form['#cache']['tags'] = $config->getCacheTags(); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $register = $account->isAnonymous(); diff --git a/core/modules/user/src/Form/UserCancelForm.php b/core/modules/user/src/Form/UserCancelForm.php index d3b6921..3223f14 100644 --- a/core/modules/user/src/Form/UserCancelForm.php +++ b/core/modules/user/src/Form/UserCancelForm.php @@ -7,6 +7,7 @@ namespace Drupal\user\Form; +use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; @@ -76,6 +77,7 @@ public function getConfirmText() { public function buildForm(array $form, FormStateInterface $form_state) { $user = $this->currentUser(); $this->cancelMethods = user_cancel_methods(); + $config = $this->config('user.settings'); // Display account cancellation method selection, if allowed. $admin_access = $user->hasPermission('administer users'); @@ -98,7 +100,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#description' => $this->t('When enabled, the user must confirm the account cancellation via email.'), ); // Also allow to send account canceled notification mail, if enabled. - $default_notify = $this->config('user.settings')->get('notify.status_canceled'); + $default_notify = $config->get('notify.status_canceled'); $form['user_cancel_notify'] = array( '#type' => 'checkbox', '#title' => $this->t('Notify user when account is canceled'), @@ -112,6 +114,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); + return $form; } diff --git a/core/modules/user/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php index 999a7cd..a0c0876 100644 --- a/core/modules/user/src/Form/UserLoginForm.php +++ b/core/modules/user/src/Form/UserLoginForm.php @@ -7,6 +7,7 @@ namespace Drupal\user\Form; +use Drupal\Core\Cache\Cache; use Drupal\Core\Flood\FloodInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; @@ -78,13 +79,15 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { + $config = $this->config('system.site'); + // Display login form: $form['name'] = array( '#type' => 'textfield', '#title' => $this->t('Username'), '#size' => 60, '#maxlength' => USERNAME_MAX_LENGTH, - '#description' => $this->t('Enter your @s username.', array('@s' => $this->config('system.site')->get('name'))), + '#description' => $this->t('Enter your @s username.', array('@s' => $config->get('name'))), '#required' => TRUE, '#attributes' => array( 'autocorrect' => 'off', @@ -109,6 +112,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#validate'][] = '::validateAuthentication'; $form['#validate'][] = '::validateFinal'; + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); + return $form; }