With hook_modules_uninstalled, we can automatically remove blocks provided by uninstalled modules. Patch following shortly.

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new805 bytes

Patch is in.

Status: Needs review » Needs work

The last submitted patch failed testing.

dave reid’s picture

Hmm... interesting failure...

dave reid’s picture

dropcube’s picture

Actually, blocks provided by uninstalled modules are removed the next time _block_rehash runs.

If we have hook_block as a registry style hooks, that can be done automatically during the hooks rebuild (or system clean-up) triggered when a module is activated/deactivated/uninstalled.

mr.baileys’s picture

Status: Needs work » Needs review
StatusFileSize
new801 bytes

#357321: Rename hook_permission() into hook_permission_info() for consistency has been pushed back to D8...

Attached is an updated patch that also clears block_role.

_block_rehash could be an alternative, but it doesn't seem to clear the block_role and block_node_type tables.

dries’s picture

So, is this useful given that we also call _block_rehash()?

Looking at _block_rehash() it doesn't look like it takes care of the block_role and block_node_type tables. Could be a bug ...

mr.baileys’s picture

We could call _block_rehash in the block_modules_uninstalled implementation, but

  1. _block_rehash is theme specific (where theme is passed either through the parameter or set to the current theme), which makes it unsuited for this task. Uninstalling a module should remove the block data for all themes. Note that there is some work being done on this in #148531: make _block_rehash() reusable
  2. Doesn't clear the block_* tables, just block itself (I do think this is a bug, but it is also addressed in #148531: make _block_rehash() reusable)
moshe weitzman’s picture

SUbscribe. IMo, this is worth doing. Lets be tidy about uninstall.

andypost’s picture

andypost’s picture

Also I'd like to point that some modules have no hook_schema() and hook_uninstall() so hook_modules_uninstalled never called!

mr.baileys’s picture

Status: Needs review » Closed (duplicate)

@andypost, agreed that the changes discussed here are covered by #735900: Deleting module's blocks when module is uninstalled and #684774: Block visibility settings cannot be properly extended. Since obviously more work has gone into those issues, and parts have already been commited, I think it's best to mark this one as a duplicate of those and continue the discussion there.