After changing the "Available as block" advanced setting for a webform, it does not show up in a blockreference select list until we actually visit the admin>settings>block page.

A workaround adds the following hook to our module:

/**
* Implements hook_node_insert().
*/
function custom_module_node_insert($node) {
  block_flush_caches();
}

The patch below adds `block_flush_caches();` to both webform_node_insert and webform_node_update.

Comments

Status:Active» Reviewed & tested by the community

Works great for me. This will also be useful for other modules that integrate with blocks that rely on the blocks table without doing a rehash.

Status:Reviewed & tested by the community» Needs work

This patch would be better if it checked $node->original in hook_node_update() to see if the block status changed. That would make it so that disabling a block would automatically remove it from the list, and it would prevent rebuilding the block list every time a node was updated. The hook_node_insert() implementation looks good.

Status:Needs work» Needs review
StatusFileSize
new733 bytes

Here's an updated patch that checks $node->original (or actually just $original, since we've already shortened this variable) in hook_node_update().

Status:Needs review» Fixed

Tested on D7 branches and things look good. Committed and pushed.

Status:Fixed» Closed (fixed)

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