Delete block settings when removing a block from hook_block_info() My module creates blocks. These may come and go and I want to make sure I'm not leaving cruft behind, e.g. settings from the configure block screen for blocks that no longer exist (i.e. are no longer returned by my hook_block_info()).

I've noticed that removing a block and then adding a new one (with the same delta) magically brings up the old config.

What should I do in my module to clean out this config? (or is it somehow done for me in an occasional cron?)
I hope this should work if I get your question right.

db_delete('block')
  -&gt;condition('module', MODULE)
  -&gt;condition('delta', DELTA)
  -&gt;execute();
db_delete('block_node_type')
  -&gt;condition('module', MODULE)
  -&gt;condition('delta', DELTA)
  -&gt;execute();
db_delete('block_role')
  -&gt;condition('module', MODULE)
  -&gt;condition('delta', DELTA)
  -&gt;execute();

cache_clear_all(MODULE_DELTA, 'cache_block');


Where MODULE resembles your module name and DELTA resembles your block's delta.