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.
When you have a default theme set that is different from the admin theme it does not rehash the appropriate theme. To replicate this set up a default standard Drupal installation install nodeblock 7.x-1.2 and set it up to a content type. Create a node of that content type and watch the block table in the database. The theme column of that record will match the admin theme.
Here is a fix attached.
Comment | File | Size | Author |
---|---|---|---|
#2 | nodeblock_rehash-1759196-1.patch | 1.48 KB | David Stosik |
#1 | nodeblock_rehash-1759196.patch | 1.02 KB | David Stosik |
fix_nodeblock_block_rehash_issue.patch | 316 bytes | tyhullinger |
Comments
Comment #1
David Stosik CreditAttribution: David Stosik commentedActually, the code is not that wrong, as inserted block is coherent, and no big bug is provoked, as going to admin/structure/block will call _block_rehash() for your current theme.
But, I would say that current code is kind of incomplete: either no _block_rehash() should be called at all during node save, or, it should be called on all active themes (if we want to update blocks list, let's do it fully, or not at all).
As there are some modules out there that don't call _block_rehash() because it is time consuming, and just assume that block table is always up-to-date (which is not the case with current code), I suggest calling _block_rehash() on all active themes.
Please find my patch attached.
Comment #2
David Stosik CreditAttribution: David Stosik commentedAnd here is a better patch replacing another _block_rehash() call in delete hook.
Comment #3
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedI've added this patch but I'm still thinking about removing the block_rehash completely from the module as I don't think this needs to be done by nodeblocks.
http://drupalcode.org/project/nodeblock.git/commit/a22093f
Comment #5
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedReplaced the block rehash:
http://drupalcode.org/project/nodeblock.git/commitdiff/f6aa32d