diff --git a/includes/common.inc b/includes/common.inc index 6cdd22b..9fb02b1 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -7170,7 +7170,10 @@ function drupal_flush_all_caches() { system_rebuild_theme_data(); drupal_theme_rebuild(); + // Rebuild node types before clearing entity info, so all node types are + // reflected when building entity info. node_types_rebuild(); + entity_info_cache_clear(); // node_menu() defines menu items based on node types so it needs to come // after node types are rebuilt. menu_rebuild(); diff --git a/includes/module.inc b/includes/module.inc index 3a019f2..b30ea19 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -545,6 +545,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { // Update the registry to remove the newly-disabled module. registry_update(); _system_update_bootstrap_status(); + entity_info_cache_clear(); } // If there remains no more node_access module, rebuilding will be diff --git a/modules/simpletest/tests/entity_cache_test_dependency.module b/modules/simpletest/tests/entity_cache_test_dependency.module index 73a1149..2d4b3be 100644 --- a/modules/simpletest/tests/entity_cache_test_dependency.module +++ b/modules/simpletest/tests/entity_cache_test_dependency.module @@ -11,7 +11,7 @@ function entity_cache_test_dependency_entity_info() { return array( 'entity_cache_test' => array( - 'label' => 'Entity Cache Test', + 'label' => variable_get('entity_cache_test_label', 'Entity Cache Test'), ), ); } diff --git a/modules/system/system.test b/modules/system/system.test index 8b305bc..01a8048 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -272,12 +272,32 @@ class EnableDisableTestCase extends ModuleTestCase { } /** - * Tests entity cache after enabling a module with a dependency on an enitity - * providing module. + * Ensures entity info cache is updated after changes. + */ + function testEntityInfoChanges() { + module_enable(array('entity_cache_test')); + $entity_info = entity_get_info(); + $this->assertTrue(isset($entity_info['entity_cache_test']), 'Test entity type found.'); + + // Change the label of the test entity type and make sure changes appear + // after flushing caches. + variable_set('entity_cache_test_label', 'New label.'); + drupal_flush_all_caches(); + $info = entity_get_info('entity_cache_test'); + $this->assertEqual($info['label'], 'New label.', 'New label appears in entity info.'); + + // Disable the providing module and make sure the entity type is gone. + module_disable(array('entity_cache_test', 'entity_cache_test_dependency')); + $entity_info = entity_get_info(); + $this->assertFalse(isset($entity_info['entity_cache_test']), 'Entity type of the providing module is gone.'); + } + + /** + * Tests entity info cache after enabling a module with a dependency on an entity providing module. * * @see entity_cache_test_watchdog() */ - function testEntityCache() { + function testEntityInfoCacheWatchdog() { module_enable(array('entity_cache_test')); $info = variable_get('entity_cache_test'); $this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.');