We need to efficiently rebuild caches when rebuilding the defaults of exportable entities.

When Rules saves a new configuration, it has to clear its caches in order to update the actions/conditions that are available for a component and/or to update caches for efficient execution of reaction rules or components.
However, any operations running on Rules configuration insert/update that require the rules cache would so trigger rules cache building, whereas the next update would flush the cache again - leading to repeated cache builds and bad performance.

Thus, we need to add a hook that allows modules to efficiently act on configuration mass-updates as occurring when rebuilding defaults in code. The Rules use-case is for rules-i18n at #1422996: localization and i18n integration, which needs to scan for translatable action parameters that have changed and requires the rules-cache to do so.

CommentFileSizeAuthor
#1 entity_defaults_hook.patch2.05 KBfago
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

FileSize
2.05 KB

attached patch implements the following hook (as added to docs template):

/**
* Act after rebuilding default {ENTITIES}.
*
* This hook is invoked by the entity module after default {ENTITIES}
* have been rebuilt; i.e. defaults have been saved to the database.
*
* @param {$ENTITIES}
*   The array of default {ENTITIES} which have been inserted or
*   updated, keyed by name.
* @param $originals
*   An array of original {ENTITIES} keyed by name; i.e. the {ENTITIES}
*   before the current defaults have been applied. For inserted
*   {ENTITIES} no original is available.
*
* @see hook_default_{ENTITY_TYPE}()
* @see entity_defaults_rebuild()
*/
function hook_{ENTITY_TYPE}_defaults_rebuild({$ENTITIES}, $originals) {
}

Committed.

fago’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.