diff --git a/README.txt b/README.txt index ed048e4..745dd7f 100644 --- a/README.txt +++ b/README.txt @@ -11,7 +11,15 @@ entity CRUD controller, which helps simplifying the creation of new entity types This is an API module. You only need to enable it if a module depends on it or you are interested in using it for development. -This README is for interested developers. If you are not interested in +Advanced usage: +--------------- +You can optimize cache clearing performance by setting the variable +'entity_rebuild_on_flush' to FALSE. This skips rebuilding of feature +components and exported entities during cache flushing. Instead, it is triggered +by the features module only; e.g., when features are reverted. + + +The README below is for interested developers. If you are not interested in developing, you may stop reading now. -------------------------------------------------------------------------------- diff --git a/entity.features.inc b/entity.features.inc index e266aaf..e394169 100644 --- a/entity.features.inc +++ b/entity.features.inc @@ -7,6 +7,12 @@ /** * Returns the configured entity features controller. + * + * @param string $type + * The entity type to get the controller for. + * + * @return EntityDefaultFeaturesController + * The configured entity features controller. */ function entity_features_get_controller($type) { $static = &drupal_static(__FUNCTION__); @@ -146,6 +152,8 @@ function entity_features_api() { } /** + * Implements hook_features_export_options(). + * * Features component callback. */ function entity_features_export_options($a1, $a2 = NULL) { @@ -157,6 +165,8 @@ function entity_features_export_options($a1, $a2 = NULL) { } /** + * Implements hook_features_export(). + * * Features component callback. */ function entity_features_export($data, &$export, $module_name = '', $entity_type) { @@ -164,6 +174,8 @@ function entity_features_export($data, &$export, $module_name = '', $entity_type } /** + * Implements hook_features_export_render(). + * * Features component callback. */ function entity_features_export_render($module, $data, $export = NULL, $entity_type) { @@ -171,8 +183,23 @@ function entity_features_export_render($module, $data, $export = NULL, $entity_t } /** + * Implements hook_features_revert(). + * * Features component callback. */ function entity_features_revert($module = NULL, $entity_type) { return entity_features_get_controller($entity_type)->revert($module); } + +/** + * Implements hook_features_post_restore(). + * + * Rebuild all defaults when a features rebuild is triggered - even the ones not + * handled by features itself. + */ +function entity_features_post_restore($op, $items = array()) { + if ($op == 'rebuild') { + // Use features rebuild to rebuild the features independent exports too. + entity_defaults_rebuild(); + } +} diff --git a/entity.install b/entity.install index f6f8cc2..118820b 100644 --- a/entity.install +++ b/entity.install @@ -14,6 +14,14 @@ function entity_enable() { } /** + * Implements hook_uninstall(). + */ +function entity_uninstall() { + // Delete variables. + variable_del('entity_rebuild_on_flush'); +} + +/** * The entity API modules have been merged into a single module. */ function entity_update_7000() { diff --git a/entity.module b/entity.module index d4a882c..1804762 100644 --- a/entity.module +++ b/entity.module @@ -1076,7 +1076,8 @@ function entity_flush_caches() { // case of enabling or disabling modules we already rebuild defaults in // entity_modules_enabled() and entity_modules_disabled(), so we do not need // to do it again. - if (current_path() != 'admin/modules/list/confirm') { + // Also check if rebuilding on cache flush is explicitly disabled. + if (current_path() != 'admin/modules/list/confirm' && variable_get('entity_rebuild_on_flush', TRUE)) { entity_defaults_rebuild(); }