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/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index 3ff21f6..4a9c48c 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -10,6 +10,7 @@ use Drupal\block\Event\BlockContextEvent; use Drupal\block\Event\BlockEvents; use Drupal\Component\Utility\Html; +use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Executable\ExecutableManagerInterface; @@ -108,10 +109,11 @@ public static function create(ContainerInterface $container) { */ public function form(array $form, FormStateInterface $form_state) { $entity = $this->entity; + $config = $this->config('system.theme'); // Store theme settings in $form_state for use below. if (!$theme = $entity->getTheme()) { - $theme = $this->config('system.theme')->get('default'); + $theme = $config->get('default'); } $form_state->set('block_theme', $theme); @@ -176,6 +178,7 @@ public function form(array $form, FormStateInterface $form_state) { '#suffix' => '', ); $form['#attached']['library'][] = 'block/drupal.block.admin'; + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return $form; } diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index cc6b8bb..6b7e8a2 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -317,7 +317,8 @@ public function getBookParents(array $item, array $parent = array()) { * A parent selection form element. */ protected function addParentSelectFormElements(array $book_link) { - if ($this->configFactory->get('book.settings')->get('override_parent_selector')) { + $config = $this->configFactory->get('book.settings'); + if ($config->get('override_parent_selector')) { return array(); } // Offer a message or a drop-down to choose a different parent page. @@ -352,6 +353,7 @@ protected function addParentSelectFormElements(array $book_link) { '#suffix' => '', ); } + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return $form; } diff --git a/core/modules/book/src/Form/BookSettingsForm.php b/core/modules/book/src/Form/BookSettingsForm.php index 0db0dc5..143d995 100644 --- a/core/modules/book/src/Form/BookSettingsForm.php +++ b/core/modules/book/src/Form/BookSettingsForm.php @@ -7,6 +7,7 @@ namespace Drupal\book\Form; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; @@ -51,6 +52,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#required' => TRUE, ); $form['array_filter'] = array('#type' => 'value', '#value' => TRUE); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return parent::buildForm($form, $form_state); } diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index fbb7442..e198154 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -10,6 +10,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Cache\Cache; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; @@ -78,6 +79,7 @@ public function form(array $form, FormStateInterface $form_state) { $entity = $this->entityManager->getStorage($comment->getCommentedEntityTypeId())->load($comment->getCommentedEntityId()); $field_name = $comment->getFieldName(); $field_definition = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$comment->getFieldName()]; + $config = $this->config('user.settings'); // Use #comment-form as unique jump target, regardless of entity type. $form['#id'] = drupal_html_id('comment_form'); @@ -147,7 +149,7 @@ public function form(array $form, FormStateInterface $form_state) { ); if ($is_admin) { $form['author']['name']['#title'] = $this->t('Authored by'); - $form['author']['name']['#description'] = $this->t('Leave blank for %anonymous.', array('%anonymous' => $this->config('user.settings')->get('anonymous'))); + $form['author']['name']['#description'] = $this->t('Leave blank for %anonymous.', array('%anonymous' => $config->get('anonymous'))); $form['author']['name']['#autocomplete_route_name'] = 'user.autocomplete'; } elseif ($this->currentUser->isAuthenticated()) { @@ -157,7 +159,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['author']['name']['#account'] = $this->currentUser; } elseif($this->currentUser->isAnonymous()) { - $form['author']['name']['#attributes']['data-drupal-default-value'] = $this->config('user.settings')->get('anonymous'); + $form['author']['name']['#attributes']['data-drupal-default-value'] = $config->get('anonymous'); } // Add author email and homepage fields depending on the current user. @@ -207,6 +209,8 @@ public function form(array $form, FormStateInterface $form_state) { '#value' => ($comment->id() ? !$comment->getOwnerId() : $this->currentUser->isAnonymous()), ); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); + return parent::form($form, $form_state, $comment); } 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/ContactFormEditForm.php b/core/modules/contact/src/ContactFormEditForm.php index 420be7d..d219519 100644 --- a/core/modules/contact/src/ContactFormEditForm.php +++ b/core/modules/contact/src/ContactFormEditForm.php @@ -7,6 +7,7 @@ namespace Drupal\contact; +use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; @@ -34,7 +35,8 @@ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $contact_form = $this->entity; - $default_form = $this->config('contact.settings')->get('default_form'); + $config = $this->config('contact.settings'); + $default_form = $config->get('default_form'); $form['label'] = array( '#type' => 'textfield', @@ -78,6 +80,7 @@ public function form(array $form, FormStateInterface $form_state) { '#default_value' => $default_form === $contact_form->id(), ); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return $form; } 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/language/src/Form/NegotiationSelectedForm.php b/core/modules/language/src/Form/NegotiationSelectedForm.php index 57194f9..4b212b7 100644 --- a/core/modules/language/src/Form/NegotiationSelectedForm.php +++ b/core/modules/language/src/Form/NegotiationSelectedForm.php @@ -7,6 +7,7 @@ namespace Drupal\language\Form; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Form\ConfigFormBase; @@ -41,6 +42,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#languages' => LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT, '#default_value' => $config->get('selected_langcode'), ); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); return parent::buildForm($form, $form_state); } diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php index fa1cd3e..dea6aba 100644 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@ -7,6 +7,7 @@ namespace Drupal\language\Form; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -131,6 +132,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form_state->setRedirect('language.negotiation'); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); + return parent::buildForm($form, $form_state); } diff --git a/core/modules/locale/src/Form/LocaleSettingsForm.php b/core/modules/locale/src/Form/LocaleSettingsForm.php index 4ff2c33..958cb44 100644 --- a/core/modules/locale/src/Form/LocaleSettingsForm.php +++ b/core/modules/locale/src/Form/LocaleSettingsForm.php @@ -6,6 +6,7 @@ namespace Drupal\locale\Form; +use Drupal\Core\Cache\Cache; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; @@ -85,6 +86,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#description' => t('How to treat existing translations when automatically updating the interface translations.'), ); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); + return parent::buildForm($form, $form_state); } 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/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index daa2868..e1d9720 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -22,6 +22,7 @@ public function form(array $form, FormStateInterface $form_state) { $term = $this->entity; $vocab_storage = $this->entityManager->getStorage('taxonomy_vocabulary'); $vocabulary = $vocab_storage->load($term->bundle()); + $config = $this->config('taxonomy.settings'); $parent = array_keys(taxonomy_term_load_parents($term->id())); $form_state->set(['taxonomy', 'parent'], $parent); @@ -38,7 +39,7 @@ public function form(array $form, FormStateInterface $form_state) { // numbers of items so we check for taxonomy.settings:override_selector // before loading the full vocabulary. Contrib modules can then intercept // before hook_form_alter to provide scalable alternatives. - if (!$this->config('taxonomy.settings')->get('override_selector')) { + if (!$config->get('override_selector')) { $parent = array_keys(taxonomy_term_load_parents($term->id())); $children = taxonomy_get_tree($vocabulary->id(), $term->id()); @@ -88,6 +89,8 @@ public function form(array $form, FormStateInterface $form_state) { '#value' => $term->id(), ); + $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags()); + return parent::form($form, $form_state, $term); } 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; } diff --git a/core/modules/user/src/Form/UserPasswordResetForm.php b/core/modules/user/src/Form/UserPasswordResetForm.php index 69b4588..303a21e 100644 --- a/core/modules/user/src/Form/UserPasswordResetForm.php +++ b/core/modules/user/src/Form/UserPasswordResetForm.php @@ -93,6 +93,8 @@ public function buildForm(array $form, FormStateInterface $form_state, AccountIn '#type' => 'submit', '#value' => $this->t('Log in'), ); + + $form['#cache']['tags'] = $this->config('user.settings')->getCacheTags(); return $form; }