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?

CommentFileSizeAuthor
#17 1194880-17.patch4.65 KBswentel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexbk66-’s picture

I 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?

alexbk66-’s picture

Title: Saving cache mode suddenly stopped working » _block_rehash() overwrites the caching mode set by Block_Cache_Alter module

Changing title

swentel’s picture

Yes, 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.

alexbk66-’s picture

For now I removed from block.module the following code:

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']);

because it's is based on the wrong assumption:

The only exceptions are 'cache' which is only definable and updatable in the code

I'm afraid now it won't save the caching mode defined in code, so I have to set every block mode manually.

thedavidmeister’s picture

subscribe

thedavidmeister’s picture

the 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 :)

thedavidmeister’s picture

scratch 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.

thedavidmeister’s picture

hrm, 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..

csavio’s picture

Seeing this problem as well with Drupal 6.22 and Block Cache Alter. The change in #4 allows the cache mode to be saved.

mr.j’s picture

Subscribing.

Wolfflow’s picture

subscribe

dmgenesys’s picture

Subscribe

lotyrin’s picture

sub

FreekVR’s picture

Subscribe

Fabianx’s picture

Status: Active » Needs work

As stated in #1173012: Blocks lose settings during update.php and cache clears this can be fixed the following way:

For blockcache_alter (an affected module by ) it can simply save the cache var into its own table, when overridden and implement an form alter on the block admin form (which comes after the _rehash()) and implement hook_flush_caches.

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.

swentel’s picture

FileSize
4.65 KB

This patch does the suggested changes metioned in #16. It feels akward, but it works.

swentel’s picture

Status: Needs work » Needs review
Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

I 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 :-).

swentel’s picture

Status: Reviewed & tested by the community » Fixed

ok, great, committed and pushed and a new release will be out in a couple of minutes!

Status: Fixed » Closed (fixed)

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