diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 82169c7..7317ed8 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -264,9 +264,8 @@ public function submit(array $form, array &$form_state) { */ public function save(array $form, array &$form_state) { // Clear the render cache. - $entity = $this->getEntity($form_state); try { - \Drupal::service('plugin.manager.entity')->getRenderController($entity->entityType())->resetCache(array($entity)); + \Drupal::service('plugin.manager.entity')->getRenderController($this->entity->entityType())->resetCache(array($this->entity)); } catch (\Exception $e) { // Nothing to do if the entity type doesn't have a render controller. diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 49df38c..0025e8e 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -203,7 +203,7 @@ function comment_admin_overview_submit($form, &$form_state) { } drupal_set_message(t('The update has been performed.')); $form_state['redirect'] = 'admin/content/comment'; - \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); cache_invalidate_tags(array('content' => TRUE)); } @@ -315,7 +315,7 @@ function comment_confirm_delete_submit($form, &$form_state) { drupal_set_message(t('The comment and all its replies have been deleted.')); watchdog('content', 'Deleted comment @cid and its replies.', array('@cid' => $comment->id())); // Clear the cache so an anonymous user sees that his comment was deleted. - \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); cache_invalidate_tags(array('content' => TRUE)); $form_state['redirect'] = "node/{$comment->nid->target_id}"; diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index de883aa..b26161c 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1947,7 +1947,7 @@ function comment_unpublish_by_keyword_action_submit($form, $form_state) { */ function comment_save_action(Comment $comment) { comment_save($comment); - \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); cache_invalidate_tags(array('content' => TRUE)); watchdog('action', 'Saved comment %title', array('%title' => $comment->subject->value)); } diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index d42efa8..3e84048 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -119,7 +119,7 @@ function comment_approve(Comment $comment) { $comment->status->value = COMMENT_PUBLISHED; $comment->save(); - \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); + Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(array($comment)); drupal_set_message(t('Comment approved.')); drupal_goto('node/' . $comment->nid->target_id); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index c023c56..369a09e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -267,6 +267,7 @@ function setCommentsPerPage($number) { */ function setCommentSettings($name, $value, $message) { variable_set($name . '_article', $value); + \Drupal::service('plugin.manager.entity')->getRenderController('comment')->resetCache(); // Display status message. $this->pass($message); } diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php index a46b465..6646714 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php @@ -106,6 +106,14 @@ public function view(EntityInterface $entity, $langcode, array $items) { '#formatter' => $this->getPluginId(), ); + // Gather cache tags from reference fields. + foreach ($items as $item) { + if (isset($item['entity'])) { + $info['#cache']['tags'][$item['entity']->entityType()][] = $item['entity']->id(); + $info['#cache']['tags'][$item['entity']->entityType() . '_view'] = TRUE; + } + } + $addition[$field['field_name']] = array_merge($info, $elements); } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php index 836cc88..9a354ad 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php @@ -496,6 +496,9 @@ public function submitForm(array &$form, array &$form_state) { field_bundle_settings($this->entity_type, $this->bundle, $bundle_settings); } + // Clear the render cache for this entity type. + \Drupal::service('plugin.manager.entity')->getRenderController($this->entity_type)->resetCache(); + drupal_set_message(t('Your settings have been saved.')); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 705ff60..59b5412 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -333,6 +333,7 @@ function testTermInterface() { // Check that it does NOT show a description when description is blank. $term->description = ''; taxonomy_term_save($term); + \Drupal::service('plugin.manager.entity')->getRenderController('taxonomy_term')->resetCache(array($term)); $this->drupalGet('taxonomy/term/' . $term->id()); $this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.'); diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index 929543d..3494b0b 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -513,13 +513,15 @@ function taxonomy_term_confirm_delete($form, &$form_state, Term $term) { * @see taxonomy_term_confirm_delete() */ function taxonomy_term_confirm_delete_submit($form, &$form_state) { - taxonomy_term_delete($form_state['values']['tid']); + $entity = taxonomy_term_load($form_state['values']['tid']); + $entity->delete(); taxonomy_check_vocabulary_hierarchy($form_state['taxonomy']['vocabulary'], $form_state['values']); drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name']))); watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE); if (!isset($_GET['destination'])) { $form_state['redirect'] = 'admin/structure/taxonomy'; } + Drupal::service('plugin.manager.entity')->getRenderController('taxonomy_term')->resetCache(array($entity)); cache_invalidate_tags(array('content' => TRUE)); return; }