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.
For some reason when I change block caching mode, it's not saved anymore. I checked the 'block' table, the caching mode is updated for other themes, but not the current theme.
So I found the block.module calls _block_rehash() after saving the block settings, which overwrites back the updated value:
if (isset($block['cache']) && $block['cache'] != $old_blocks[$module][$delta]['cache']) {
db_query("UPDATE {blocks} SET cache = %d WHERE bid = %d", $block['cache'], $old_blocks[$module][$delta]['bid']);
}
Any ideas why?
Comment | File | Size | Author |
---|---|---|---|
#17 | 1194880-17.patch | 4.65 KB | swentel |
Comments
Comment #1
alexbk66- CreditAttribution: alexbk66- commentedI guess what _block_rehash() is doing: it checks if _block hook for a module sets the default caching mode for the block - then it updates the caching setting in {block} table with this default setting.
Does it mean that Block_Cache_Alter won't work if _block hook implementation sets the caching mode?
Comment #2
alexbk66- CreditAttribution: alexbk66- commentedChanging title
Comment #3
swentel CreditAttribution: swentel commentedYes, since that patch, this doesn't work anymore, however, I know they are going to revert the patch normally. I guess i"ll have to to take the technique I'm using for the 7 version which keeps the caching mode in a different table. However, the problem is that there is no hook to override that, so I think I might have a big problem if it will be possible at all to make this work ever again .. will investigate this further.
Comment #4
alexbk66- CreditAttribution: alexbk66- commentedFor now I removed from block.module the following code:
because it's is based on the wrong assumption:
I'm afraid now it won't save the caching mode defined in code, so I have to set every block mode manually.
Comment #5
thedavidmeister CreditAttribution: thedavidmeister commentedsubscribe
Comment #6
thedavidmeister CreditAttribution: thedavidmeister commentedthe fix posted in #4 seems to have fixed the problem for me. Thanks, although hacking core is obviously a bit of a shit way to do things.
that code is on line 278 of block.module if anyone else is looking for it.
if the only downside of this hack is that i have to manually set the cache for every block, then i'm ok with that as i've already been through them all prior to block cache alter breaking :)
Comment #7
thedavidmeister CreditAttribution: thedavidmeister commentedscratch that, the fix in #4 let me save the form, which appeared to fix the issue, but the actual caching doesn't seem to be behaving. I'm randomly getting empty outputs from cached block views now.
Comment #8
thedavidmeister CreditAttribution: thedavidmeister commentedhrm, now i'm wondering if it was an issue with boost caching something it shouldn't have between when i applied the changes in #4 and now because everything is slowly going back to normal..
Comment #10
csavio CreditAttribution: csavio commentedSeeing this problem as well with Drupal 6.22 and Block Cache Alter. The change in #4 allows the cache mode to be saved.
Comment #11
mr.j CreditAttribution: mr.j commentedSubscribing.
Comment #12
Wolfflow CreditAttribution: Wolfflow commentedsubscribe
Comment #13
dmgenesys CreditAttribution: dmgenesys commentedSubscribe
Comment #14
lotyrin CreditAttribution: lotyrin commentedsub
Comment #15
FreekVR CreditAttribution: FreekVR commentedSubscribe
Comment #16
Fabianx CreditAttribution: Fabianx commentedAs stated in #1173012: Blocks lose settings during update.php and cache clears this can be fixed the following way:
You just need to make sure to set weight high enough so you come after block module.
So the same technique as for Drupal 7 can be applied here.
Comment #17
swentel CreditAttribution: swentel commentedThis patch does the suggested changes metioned in #16. It feels akward, but it works.
Comment #18
swentel CreditAttribution: swentel commentedComment #19
Fabianx CreditAttribution: Fabianx commentedI now finally needed this on a D6 site and #17 works like a charm!
Thanks swentel, this is ready to be commited. :-)
Code-Review: CHECK
Works exactly as I proposed and I checked that its doing what I though it would do :-).
Comment #20
swentel CreditAttribution: swentel commentedok, great, committed and pushed and a new release will be out in a couple of minutes!