diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 46db8c7..e24fc29 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -128,6 +128,15 @@ public function loadMultiple(array $ids = NULL) { // array for later comparison with the entity cache, or FALSE if no $ids // were passed. $passed_ids = !empty($ids) ? array_flip($ids) : FALSE; + // Try to load entities from the static cache, if the entity type supports + // static caching. + if ($this->cache && $ids) { + $entities += $this->cacheGet($ids); + // If any entities were loaded, remove them from the ids still to load. + if ($passed_ids) { + $ids = array_keys(array_diff_key($passed_ids, $entities)); + } + } // Load any remaining entities. This is the case if $ids is set to NULL (so // we load all entities). @@ -143,13 +152,20 @@ public function loadMultiple(array $ids = NULL) { $entities += $queried_entities; } + if ($this->cache) { + // Add entities to the cache. + if (!empty($queried_entities)) { + $this->cacheSet($queried_entities); + } + } + // Ensure that the returned array is ordered the same as the original // $ids array if this was passed in and remove any invalid ids. if ($passed_ids) { // Remove any invalid ids from the array. $passed_ids = array_intersect_key($passed_ids, $entities); foreach ($entities as $entity) { - $passed_ids[$entity->{$this->idKey}] = $entity; + $passed_ids[$entity->id()] = $entity; } $entities = $passed_ids; } @@ -212,7 +228,7 @@ public static function getIDFromConfigName($config_name, $config_prefix) { * See Drupal\comment\CommentStorageController::buildQuery() or * Drupal\taxonomy\TermStorageController::buildQuery() for examples. * - * @param $ids + * @param array|null $ids * An array of entity IDs, or NULL to load all entities. * @param $revision_id * The ID of the revision to load, or FALSE if this query is asking for the @@ -298,6 +314,9 @@ public function delete(array $entities) { $config->delete(); } + // Reset the cache as soon as the changes have been applied. + $this->resetCache(array_keys($entities)); + $entity_class::postDelete($this, $entities); foreach ($entities as $entity) { $this->invokeHook('delete', $entity); @@ -360,6 +379,7 @@ public function save(EntityInterface $entity) { if (!$config->isNew()) { $return = SAVED_UPDATED; $config->save(); + $this->resetCache(array($entity->id())); $entity->postSave($this, TRUE); $this->invokeHook('update', $entity); diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index 3c9745f..5258381 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -230,6 +230,7 @@ public function testViewsBlockForm() { $edit['settings[override][items_per_page]'] = 5; $this->drupalPostForm('admin/structure/block/manage/views_block__test_view_block_block_1_4', $edit, t('Save block')); + $storage->resetCache(); $block = $storage->load('views_block__test_view_block_block_1_4'); $config = $block->getPlugin()->getConfiguration(); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php index f984160..5e603c5 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php @@ -139,6 +139,7 @@ function testAdmin() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n"; + \Drupal::entityManager()->getStorageController('editor')->resetCache(); $editor = entity_load('editor', 'filtered_html'); $this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.'); $this->assertIdentical($expected_settings, $editor->settings, 'The Editor config entity has the correct settings.'); @@ -156,6 +157,7 @@ function testAdmin() { 'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']), ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); + \Drupal::entityManager()->getStorageController('editor')->resetCache(); $editor = entity_load('editor', 'filtered_html'); $this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.'); $this->assertIdentical($expected_settings, $editor->settings, 'The Editor config entity has the correct settings.'); @@ -181,6 +183,7 @@ function testAdmin() { $ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]'); $this->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is checked.'); $expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = 1; + \Drupal::entityManager()->getStorageController('editor')->resetCache(); $editor = entity_load('editor', 'filtered_html'); $this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.'); $this->assertIdentical($expected_settings, $editor->settings); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 126fc75..7ccfdb7 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -405,6 +405,7 @@ function deleteCategories() { else { $this->drupalPostForm("admin/structure/contact/manage/$id/delete", array(), t('Delete')); $this->assertRaw(t('Category %label has been deleted.', array('%label' => $category->label()))); + \Drupal::entityManager()->getStorageController('contact_category')->resetCache(); $this->assertFalse(entity_load('contact_category', $id), format_string('Category %category not found', array('%category' => $category->label()))); } } diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php index b78131b..aedb321 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php @@ -270,14 +270,14 @@ public function testRenameDeleteBundle() { entity_create('node_type', array('type' => 'article'))->save(); entity_get_display('node', 'article', 'default')->save(); entity_get_form_display('node', 'article', 'default')->save(); - - // Rename the article bundle and assert the entity display is renamed. $type = node_type_load('article'); $type->old_type = 'article'; $type->type = 'article_rename'; $type->save(); + \Drupal::entityManager()->getStorageController('entity_display')->resetCache(); $old_display = entity_load('entity_view_display', 'node.article.default'); $this->assertFalse($old_display); + \Drupal::entityManager()->getStorageController('entity_form_display')->resetCache(); $old_form_display = entity_load('entity_form_display', 'node.article.default'); $this->assertFalse($old_form_display); $new_display = entity_load('entity_view_display', 'node.article_rename.default'); @@ -345,3 +345,5 @@ public function testDeleteFieldInstance() { } } + // Rename the article bundle and assert the entity display is renamed. + diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 119f6fa..179f961 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -39,6 +39,11 @@ function field_info_cache_clear() { \Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions(); \Drupal::service('config.factory')->reset(); + // Make sure that instantiated field definition and instance entities are + // cleared. + \Drupal::entityManager()->getStorageController('field_config')->resetCache(); + \Drupal::entityManager()->getStorageController('field_instance_config')->resetCache(); + Field::fieldInfo()->flush(); } diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 9b33354..c579931 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -160,6 +160,9 @@ public function flush() { $this->bundleExtraFields = array(); Cache::deleteTags(array('field_info' => TRUE)); + + \Drupal::entityManager()->getStorageController('field_config')->resetCache(); + \Drupal::entityManager()->getStorageController('field_instance_config')->resetCache(); } /** diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index 4a25ca6..301fe49 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -69,6 +69,7 @@ function testFormatterUI() { // Submit the form and check that the display is updated. $this->drupalPostForm(NULL, array(), t('Save')); + \Drupal::entityManager()->getStorageController('entity_display')->resetCache(); $display = entity_get_display('node', $this->type, 'default'); $display_options = $display->getComponent('field_test'); $current_format = $display_options['type']; @@ -151,6 +152,7 @@ public function testWidgetUI() { // Submit the form and check that the display is updated. $this->drupalPostForm(NULL, array(), t('Save')); + \Drupal::entityManager()->getStorageController('entity_form_display')->resetCache(); $display = entity_get_form_display('node', $this->type, 'default'); $display_options = $display->getComponent('field_test'); $current_widget = $display_options['type']; @@ -350,6 +352,8 @@ function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $message function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $message, $not_exists) { // Make sure caches on the tester side are refreshed after changes // submitted on the tested side. + \Drupal::entityManager()->getStorageController('entity_display')->resetCache(); + \Drupal::entityManager()->getStorageController('entity_form_display')->resetCache(); field_info_cache_clear(); // Save current content so that we can restore it when we're done. diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index ca50030..f62a80d 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -227,6 +227,7 @@ function filter_formats(AccountInterface $account = NULL) { function filter_formats_reset() { Cache::deleteTags(array('filter_formats' => TRUE)); drupal_static_reset('filter_formats'); + \Drupal::entityManager()->getStorageController('filter_format')->resetCache(); } /** diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php index 248a9dd..c6e22aa 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php @@ -178,6 +178,7 @@ function testFilterAdmin() { )); $this->assertTrue(!empty($elements), 'Reorder confirmed in admin interface.'); + \Drupal::entityManager()->getStorageController('filter_format')->resetCache(); $filter_format = entity_load('filter_format', $restricted); foreach ($filter_format->filters() as $filter_name => $filter) { if ($filter_name == $second_filter || $filter_name == $first_filter) { diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index a706f74..8a4dfc3 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -335,6 +335,9 @@ function editForumVocabulary() { $this->assertResponse(200); $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $edit['name'])), 'Vocabulary was edited'); + // Reset cache. + \Drupal::entityManager()->getStorageController('taxonomy_vocabulary')->resetCache(); + // Grab the newly edited vocabulary. $current_vocabulary = entity_load('taxonomy_vocabulary', $vid); diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php index 9837196..a98c8d1 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php @@ -248,6 +248,9 @@ function testStyle() { // Delete the style. $this->drupalPostForm($style_path . '/delete', array(), t('Delete')); + // Reset cache. + \Drupal::entityManager()->getStorageController('image_style')->resetCache(); + // Confirm the style directory has been removed. $directory = file_default_scheme() . '://styles/' . $style_name; $this->assertFalse(is_dir($directory), format_string('Image style %style directory removed on style deletion.', array('%style' => $style->label()))); diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php index d162cd3..aa523ef 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php @@ -231,6 +231,9 @@ public function testDefaultImages() { ) ); + // Reset cache. + \Drupal::entityManager()->getStorageController('entity_display')->resetCache(); + // Reload the nodes. $article_built = node_view($article = node_load($article->id(), TRUE)); $page_built = node_view($page = node_load($page->id(), TRUE)); @@ -266,6 +269,9 @@ public function testDefaultImages() { 'Updated article image field instance default has been successfully removed.' ); + // Reset cache. + \Drupal::entityManager()->getStorageController('entity_display')->resetCache(); + // Reload the nodes. $article_built = node_view($article = node_load($article->id(), TRUE)); $page_built = node_view($page = node_load($page->id(), TRUE)); diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php index d926528..3a1364b 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php @@ -212,6 +212,10 @@ function deleteCustomMenu() { // Delete custom menu. $this->drupalPostForm("admin/structure/menu/manage/$menu_name/delete", array(), t('Delete')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('menu')->resetCache(); + $this->assertResponse(200); $this->assertRaw(t('The custom menu %title has been deleted.', array('%title' => $label)), 'Custom menu was deleted'); $this->assertFalse(menu_load($menu_name), 'Custom menu was deleted'); diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php index a1d2c14..3e2351f 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php @@ -60,6 +60,10 @@ function testUpdateAllowedValues() { // Removed options do not appear. $this->field->settings['allowed_values'] = array(2 => 'Two'); $this->field->save(); + + // Reset cache. + \Drupal::entityManager()->getStorageController('entity_form_display')->resetCache(); + $entity = entity_create('entity_test'); $form = \Drupal::service('entity.form_builder')->getForm($entity); $this->assertTrue(empty($form[$this->fieldName]['widget'][1]), 'Option 1 does not exist'); @@ -69,6 +73,10 @@ function testUpdateAllowedValues() { // Completely new options appear. $this->field->settings['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); $this->field->save(); + + // Reset cache. + \Drupal::entityManager()->getStorageController('entity_form_display')->resetCache(); + // The entity holds an outdated field object with the old allowed values // setting, so we need to reintialize the entity object. $entity = entity_create('entity_test'); diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 0653743..9d763b7 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -67,6 +67,9 @@ function setUp() { ); $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save')); + // Reset cache. + \Drupal::entityManager()->getStorageController('node')->resetCache(); + // Ensure configuration changes are picked up in the host environment. Field::fieldInfo()->flush(); $field = Field::fieldInfo()->getField('node', 'body'); @@ -139,6 +142,9 @@ function testAliasTranslation() { $edit = array('preferred_langcode' => 'fr'); $this->drupalPostForm("user/" . $this->web_user->id() . "/edit", $edit, t('Save')); + // Reset cache. + \Drupal::entityManager()->getStorageController('node')->resetCache(); + // Check that the English alias works. In this situation French is the // current UI and content language, while URL language is English (since we // do not have a path prefix we fall back to the site's default language). diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php index 25b8ff2..5a74668 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -123,6 +123,7 @@ public function testRankings() { $this->drupalGet('admin/config/search/settings/manage/node_search'); $this->assertTrue($this->xpath('//select[@id="edit-rankings-' . $node_rank . '"]//option[@value="10"]'), 'Select list to prioritize ' . $node_rank . ' for node ranks is visible and set to 10.'); + \Drupal::entityManager()->getStorageController('search_page')->resetCache(array('node_search')); // Reload the plugin to get the up-to-date values. $this->nodeSearch = entity_load('search_page', 'node_search'); // Do the search and assert the results. diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index f367ec9..6fe8025 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -60,6 +60,10 @@ public function testShortcutLinkAdd() { ); $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save')); $this->assertResponse(200); + + // Reset cache. + \Drupal::entityManager()->getStorageController('shortcut_set')->resetCache(); + $saved_set = shortcut_set_load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'path'); $this->assertTrue(in_array($this->container->get('path.alias_manager')->getSystemPath($test['path']), $paths), 'Shortcut created: ' . $test['path']); @@ -94,6 +98,10 @@ public function testShortcutLinkRename() { $shortcuts = $set->getShortcuts(); $shortcut = reset($shortcuts); $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title' => $new_link_name, 'path' => $shortcut->path->value), t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('shortcut_set')->resetCache(); + $saved_set = shortcut_set_load($set->id()); $titles = $this->getShortcutInformation($saved_set, 'title'); $this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name); @@ -112,6 +120,10 @@ public function testShortcutLinkChangePath() { $shortcuts = $set->getShortcuts(); $shortcut = reset($shortcuts); $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title' => $shortcut->getTitle(), 'path' => $new_link_path), t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('shortcut_set')->resetCache(); + $saved_set = shortcut_set_load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'path'); $this->assertTrue(in_array($new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path); @@ -140,6 +152,10 @@ public function testShortcutLinkDelete() { $shortcuts = $set->getShortcuts(); $shortcut = reset($shortcuts); $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id() . '/delete', array(), 'Delete'); + + // Reset cache. + \Drupal::entityManager()->getStorageController('shortcut_set')->resetCache(); + $saved_set = shortcut_set_load($set->id()); $ids = $this->getShortcutInformation($saved_set, 'id'); $this->assertFalse(in_array($shortcut->id(), $ids), 'Successfully deleted a shortcut.'); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php index 9d39537..d64e47d 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php @@ -31,6 +31,10 @@ function testShortcutSetAdd() { 'id' => strtolower($this->randomName()), ); $this->drupalPostForm(NULL, $edit, t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('shortcut_set')->resetCache(); + $new_set = $this->container->get('entity.manager')->getStorageController('shortcut_set')->load($edit['id']); $this->assertIdentical($new_set->id(), $edit['id'], 'Successfully created a shortcut set.'); $this->drupalGet('user/' . $this->admin_user->id() . '/shortcuts'); @@ -98,6 +102,10 @@ function testShortcutSetRename() { $this->drupalGet('admin/config/user-interface/shortcut'); $this->clickLink(t('Edit shortcut set')); $this->drupalPostForm(NULL, array('label' => $new_label), t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('shortcut_set')->resetCache(); + $set = shortcut_set_load($set->id()); $this->assertTrue($set->label() == $new_label, 'Shortcut set has been successfully renamed.'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php index 78c8d6d..d72eb06 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php @@ -91,6 +91,10 @@ function testAdministratorRole() { // Aggregator depends on file module, enable that as well. $edit['modules[Field types][file][enable]'] = TRUE; $this->drupalPostForm('admin/modules', $edit, t('Save configuration')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('user_role')->resetCache(); + $this->assertTrue($this->admin_user->hasPermission('administer news feeds'), 'The permission was automatically assigned to the administrator role'); } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php index 2658b1a..8f2102e 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRoleAdminTest.php @@ -64,6 +64,10 @@ function testRoleAdministration() { $edit = array('label' => $role_name); $this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save')); $this->assertRaw(t('Role %label has been updated.', array('%label' => $role_name))); + + // Reset cache. + \Drupal::entityManager()->getStorageController('user_role')->resetCache(); + $new_role = entity_load('user_role', $old_name); $this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.'); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php b/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php index 3ae1dc6..cd98b05 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php @@ -62,7 +62,9 @@ public function testAccessRoleUI() { $this->assertResponse(200); $this->drupalPostForm(NULL, array(), t('Save')); - $view = $entity_manager->getStorageController('view')->load('test_access_role'); + $storage_controller = $entity_manager->getStorageController('view'); + $storage_controller->resetCache(array('test_access_role')); + $view = $storage_controller->load('test_access_role'); $display = $view->getDisplay('default'); $this->assertEqual($display['display_options']['access']['options']['role'], array('custom_role' => 'custom_role')); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaViewTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaViewTest.php index a99a316..239d13d 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaViewTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaViewTest.php @@ -54,6 +54,8 @@ public function testViewArea() { $this->assertTrue(strpos($output, 'view-test-simple-argument') !== FALSE, 'The test view is correctly embedded.'); $view->destroy(); + \Drupal::entityManager()->getStorageController('view')->resetCache(array('test_simple_argument')); + $view->setArguments(array(27)); $this->executeView($view); $output = $view->render(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php index 57427ca..6058d31 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php @@ -74,6 +74,9 @@ public function testStyle() { $output = drupal_render($output); $this->assertTrue(strpos($output, $random_text) !== FALSE, 'Make sure that the rendering of the row plugin appears in the output of the view.'); + // Reset cache. + \Drupal::entityManager()->getStorageController('view')->resetCache(); + // Test without row plugin support. $view = views_get_view('test_view'); $view->setDisplay(); diff --git a/core/modules/views/lib/Drupal/views/Views.php b/core/modules/views/lib/Drupal/views/Views.php index ba45e17..95eac75 100644 --- a/core/modules/views/lib/Drupal/views/Views.php +++ b/core/modules/views/lib/Drupal/views/Views.php @@ -187,7 +187,7 @@ public static function getApplicableViews($type) { $result = array(); foreach (\Drupal::entityManager()->getStorageController('view')->loadMultiple($entity_ids) as $view) { // Check each display to see if it meets the criteria and is enabled. - $executable = $view->getExecutable(); + $executable = static::executableFactory()->get($view); $executable->initDisplay(); foreach ($executable->displayHandlers as $id => $handler) { if (!empty($handler->definition[$type]) && $handler->isEnabled()) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php index 75aed9d..7784637 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php @@ -101,6 +101,9 @@ public function testCustomOption() { // Save the view. $this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save'); + // Reset cache. + \Drupal::entityManager()->getStorageController('view')->resetCache(); + $view = views_get_view('test_view'); $output = $view->preview(); $output = drupal_render($output); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php index 61e534b..0e77e56 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php @@ -58,6 +58,9 @@ public function testAttachmentUI() { $this->assertEqual($result[0]->attributes()->title, t('Multiple displays')); $this->drupalPostForm(NULL, array(), t('Save')); + // Reset cache. + \Drupal::entityManager()->getStorageController('view')->resetCache(); + $view = views_get_view('test_attachment_ui'); $view->initDisplay(); $this->assertEqual(array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), array('default', 'page_1'), 'The attached displays got saved as expected'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php index 9515b4b..4d1fbed 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php @@ -44,6 +44,10 @@ public function testDisplayExtenderUI() { $this->drupalPostForm($display_option_url, array('test_extender_test_option' => $random_text), t('Apply')); $this->assertLink($random_text); $this->drupalPostForm(NULL, array(), t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('view')->resetCache(); + $view = views_get_view($view->storage->id()); $view->initDisplay(); $this->assertEqual($view->display_handler->getOption('test_extender_test_option'), $random_text, 'Make sure that the display extender option got saved.'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php index 176f009..d834c76 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php @@ -109,6 +109,10 @@ public function testUICRUD() { // Save the view and have a look whether the handler was added as expected. $this->drupalPostForm(NULL, array(), t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('view')->resetCache(); + $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view_empty'); $display = $view->getDisplay('default'); $this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.'); @@ -118,6 +122,10 @@ public function testUICRUD() { $this->assertNoLinkByHref($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.'); $this->drupalPostForm(NULL, array(), t('Save')); + + // Reset cache. + \Drupal::entityManager()->getStorageController('view')->resetCache(); + $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view_empty'); $display = $view->getDisplay('default'); $this->assertFalse(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was removed from the view itself.'); @@ -139,6 +147,7 @@ public function testUICRUD() { $this->drupalPostForm(NULL, array(), t('Apply')); $this->drupalPostForm(NULL, array(), t('Save')); + $this->container->get('entity.manager')->getStorageController('view')->resetCache(); $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view_empty'); $display = $view->getDisplay('default'); $this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.');