Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | webform_block_flush_caches-1891552.patch | 733 bytes | quicksketch |
webform_node_insert.patch | 987 bytes | a-fro | |
Comments
Comment #1
james.williams CreditAttribution: james.williams commentedWorks 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.
Comment #2
quicksketchThis 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.
Comment #3
quicksketchHere's an updated patch that checks $node->original (or actually just $original, since we've already shortened this variable) in hook_node_update().
Comment #4
quicksketchTested on D7 branches and things look good. Committed and pushed.