Let plugin managers announce changed definitions

Created on 20 February 2012, about 13 years ago
Updated 25 March 2025, 11 days ago

Problem

info hooks have one major design gap: if provided info changes, how to invalidate cached dependent data?
(in dataflow speak: we have only a pull and no push mechanism.)

examples:
* if hook_menu() info changes you do a menu_rebuild() (and pray that no other modules caches hook_menu() info)
* commerce_custom_line_items.module implements hook_commerce_line_items() and hardcodes a cache clear mechanism on behalf of commerce_line_items.module

Clarification

some hooks like hook_menu() are not explicitly named hook_foo_info(), but for this issue we call them info hooks too. this might change with #1751240: Fix naming pattern of info hooks β†’ .

Proposed solution

Invoking hook_foo_info_change() notifies all modules that
* hook_foo_info() data changed
* all caches need to be cleared
* and maybe other actions taken

in contrast to today's solution to e.g. calling menu_rebuild() any module can listen to this ntification.

Example

if dynamic_foo_provider.module implementing hook_foo_info() changes their info
then it calls

  // invoke hook_foo_info_change() and clear dependent caches
  module_invoke_all('foo_info_change', 'dynamic_foo_provider');

and any foo_info_consumer.module can invalidate its cache like this

/**
 * Implements hook_foo_info_change()
 *
 * clears the cache when provided info changes 
 * @see:http://drupal.org/node/1446808 
 *
 * TODO: for now we clear our whole cache if some module announces an info change
 * we might use $module and make this more granular later
 */
function foo_info_consumer_foo_info_change($module) {
  foo_info_consumer_clear_foo_cache();
}

About $module

The $module parameter can help to partially clear cache.

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

plugin system

Created by

πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024