Comments

timaholt’s picture

Status: Active » Needs review
StatusFileSize
new19.92 KB

Hey guys, i needed a full updated version of blockcache_alter that works with D7. This is a patch that updates the d7 version. It adds a new core patch for 7, and includes some extra features over the 6.x version. Those include:

- More helpful debug mode, that prints out the state of each block that is rendered on the page
- The ability to enable block caching for user 1 (not recommended except for testing!)

The only thing that is lacks from the 6.x version is the Nodequeue support, which should be simple to add back in.

timaholt’s picture

One other note on the above patch, it allows you to turn on block caching even when modules use node grants. I figure that there's really no reason to not want this option, and so there is only one patch included. Anyone who knows enough about block caching to use this module should also understand how to set block caching when modules implement node grants. In fact for me that's probably the biggest use case for this module anyway :-)

bharata’s picture

Is there any chance this patch is in the dev? I'm still a bit iffy about applying patches.

Thanks for taking the time to reply!

timaholt’s picture

StatusFileSize
new7.44 KB

Here's an upload of the module itself for quick testing, but that patch should apply cleanly to the 7.x-1.x branch.

pfrenssen’s picture

@bharata: If you need help applying patches, take a look at Applying patches. It has step-by-step instructions and links to articles about patching on Windows and Mac OSX at the bottom. It's easy once you know how :)

fabianx’s picture

Assigned: Unassigned » fabianx

Love it!

I'll need to review this at some point ...

Anyone using this in production?

damontgomery’s picture

StatusFileSize
new15.34 KB

Here is a patch against current dev release. We've applied the core patch and this patch and are testing a bit.

ugg... use the next one.

damontgomery’s picture

StatusFileSize
new20.02 KB

Ok, I missed a few things in that last one :(.

Kazanir’s picture

pandaeskimo, I applied your patch to 7.x-1.x and added the included core patch but my debug results show that none of my blocks are caching, despite being set to cache with a large minimum lifetime and testing on both anonymous and non-user-1 authenticated users. Where should I start looking to troubleshoot this?

cuteapoot’s picture

Issue summary: View changes
StatusFileSize
new20 KB

The patch in #8 has a type in its hook_user_logout implementation. The function is looking for "&$edit," which isn't part of hook_user_logout (it is part of hook_user_login, so I'm assuming that's where the confusion came from). I've attached the same patch with that variable removed. This will get rid of any errors you get saying "Warning: Parameter 1 to blockcache_alter_user_logout() expected to be a reference, value given in module_invoke_all() (line 857 of .../module.inc).

helmo’s picture

StatusFileSize
new19.98 KB

Here's a re-roll of the patch with a re-roll of the core patch against 7.28 included.

Anonymous’s picture

We used patch #11 to cache a i18n Taxonomy menu with +/+ 4700 counted nodes, rendered in Superfish. Render time without cache 1200ms, with cache 0ms. Measured with Block Timer https://www.drupal.org/sandbox/jchin1968/2061005 (sandbox).

Hint:
If you don't like patching core (i don't like it): copy the patched block module to sites/all/modules or the costum module directory you use. Drupal wil use this version of Block.
You can safely replace the patched Block module in Drupal core with the original Block module or update Drupal core withouth patching the Block module again. Only major changes or security changes in the Block module could give problems and you have to patch the Block module again.

fabianx’s picture

Issue tags: +Needs manual testing

This will need some manual testing, but looks good on first glance.

fabianx’s picture

Status: Needs review » Needs work
  1. +++ b/blockcache_alter.module
    @@ -6,6 +6,61 @@
    +    '#title' => t('Show debug information ?'),
    +    '#description' => t('Debug info: shows helpful debugging whenever blocks are rendered, whether they are pulled form cache or not, and when block caches are refreshed.'),
    ...
    +    '#title' => t('Cache blocks for user 1 (uid 1) ?'),
    +    '#description' => t('This enables block caching for the primary Drupal user (uid 1).  Can lead to unexpected results on production websites!'),
    

    These will only work with corepatch enabled, so also needs #states support.

  2. +++ b/blockcache_alter.module
    @@ -6,6 +6,61 @@
    +  // Add some funky hide and show javascript.
    +  drupal_add_js(drupal_get_path('module', 'blockcache_alter') . '/blockcache_alter.js');
    +}
    

    This should be done with #states API ...

  3. +++ b/blockcache_alter.module
    @@ -47,11 +111,109 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) {
    +      '#prefix' => '<div id="blockcache_alter_wrapper" style="display: '. $display .';">',
    ...
    +        '#prefix' => '<div style="float: left;">',
    +        '#suffix' => '</div>',
    ...
    +        '#prefix' => '<div style="float: left; margin-left: 15px;">',
    +        '#suffix' => '</div><div style="clear: both;"></div>',
    

    This really should use classes.

  4. +++ b/blockcache_alter.module
    @@ -47,11 +111,109 @@ function blockcache_alter_form_alter(&$form, $form_state, $form_id) {
    +      $form['cache']['enddiv'] = array(
    +        '#type' => 'hidden',
    +        '#suffix' => '</div>',
    +      );
    

    This should use #markup => '

    '.

    Though this should just have a #theme => container in the $form['cache'].

Unfortunately needs some cosmetic work, besides that works fine.

pal4life’s picture

Confused, what is the end result and if any of these work fine?

Is this the right summary?

#12 - Hacks core :)

jhedstrom’s picture

Status: Needs work » Needs review
StatusFileSize
new5.69 KB
new18.84 KB
new3.96 KB

This attempts to address the issues in #14. For the styling ones, I simply removed the divs and inline styles to simplify the code.

I'm also directly attaching the patch to this issue for ease of use with drush make. If this patch gets committed, it would be nice to directly link the patch from the project page.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community

**RTBM** - looks great to me, will leave for some time in that state, then apply to HEAD

ollie222’s picture

#16 looks to be working for me too.

jhedstrom’s picture

StatusFileSize
new483 bytes
new0 bytes

Patch in #16 was causing PHP warnings in PHP 5.5:

PHP Warning: Parameter 1 to blockcache_alter_user_delete() expected to be a reference, value given in /opt/development/integration.vista/drupal/includes/module.inc on line 895

This fixes the hook to be properly declared.

jhedstrom’s picture

StatusFileSize
new18.82 KB

Oops, malformed patch above.

fabianx’s picture

Status: Reviewed & tested by the community » Needs work

CNW, per #20. Thanks, jhedstrom!

jhedstrom’s picture

Status: Needs work » Needs review

Needs review I think.

fabianx’s picture

Since Drupal 7.33 there is now a new option to override the node grants problem:

'block_cache_bypass_node_grants'

I assume we should adjust the patch to that ...

Leaving at CNR for now.

fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, I will adjust the core patch some during commit ...

fabianx’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x-1.x.

We need to re-port the core patch to the new version now though, I opened #2371599: Port BCA patch to Drupal 7.33 as follow-up.

Thanks all!

  • Fabianx committed 2bd2760 on 7.x-1.x authored by timaholt
    Issue #1562700 by jhedstrom, pandaeskimo, helmo, bobojo, timaholt |...

Status: Fixed » Closed (fixed)

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