/[drupal]/contributions/modules/advcache/DRUPAL-5-6/block_cache.patch
ViewVC logotype

Diff of /contributions/modules/advcache/DRUPAL-5-6/block_cache.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by robertDouglass, Fri Jul 18 20:54:49 2008 UTC revision 1.2 by mikejoconnor, Thu Feb 26 13:39:12 2009 UTC
# Line 0  Line 1 
1    diff -Naur ../drupal/modules/block/block.module ./modules/block/block.module
2    --- ../drupal/modules/block/block.module        2007-09-12 03:49:35.000000000 -0400
3    +++ ./modules/block/block.module        2007-12-10 12:33:03.482126894 -0500
4    @@ -286,6 +286,7 @@
5       }
6       drupal_set_message(t('The block settings have been updated.'));
7       cache_clear_all();
8    +  cache_clear_all('*', 'cache_advcache_block', TRUE);
9     }
10    
11     /**
12    @@ -500,6 +501,7 @@
13         module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values);
14         drupal_set_message(t('The block configuration has been saved.'));
15         cache_clear_all();
16    +    cache_clear_all('*', 'cache_advcache_block', TRUE);
17         return 'admin/build/block';
18       }
19     }
20    @@ -538,6 +540,7 @@
21       db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_values['bid']);
22       drupal_set_message(t('The block %name has been removed.', array('%name' => $form_values['info'])));
23       cache_clear_all();
24    +  cache_clear_all('*', 'cache_advcache_block', TRUE);
25       return 'admin/build/block';
26     };
27    
28    @@ -643,26 +646,39 @@
29       static $blocks = array();
30    
31       if (!count($blocks)) {
32    -    $rids = array_keys($user->roles);
33    -    $placeholders = implode(',', array_fill(0, count($rids), '%d'));
34    -    $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN ($placeholders) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", array_merge(array($theme_key), $rids));
35    -    while ($block = db_fetch_object($result)) {
36    -      if (!isset($blocks[$block->region])) {
37    -        $blocks[$block->region] = array();
38    -      }
39    -      // Use the user's block visibility setting, if necessary
40    -      if ($block->custom != 0) {
41    -        if ($user->uid && isset($user->block[$block->module][$block->delta])) {
42    -          $enabled = $user->block[$block->module][$block->delta];
43    +    $cache_key = $user->uid. '::'. $theme_key;
44    +    $cache = cache_get($cache_key, 'cache_advcache_block');
45    +    $enabled_blocks = unserialize($cache->data);
46    +    if (empty($enabled_blocks)) {
47    +      $enabled_blocks = array();
48    +      $rids = array_keys($user->roles);
49    +      $placeholders = implode(',', array_fill(0, count($rids), '%d'));
50    +      $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN ($placeholders) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", array_merge(array($theme_key), $rids));
51    +      while ($block = db_fetch_object($result)) {
52    +        if (!isset($blocks[$block->region])) {
53    +          $blocks[$block->region] = array();
54    +        }
55    +        // Use the user's block visibility setting, if necessary
56    +        if ($block->custom != 0) {
57    +          if ($user->uid && isset($user->block[$block->module][$block->delta])) {
58    +            $enabled = $user->block[$block->module][$block->delta];
59    +          }
60    +          else {
61    +            $enabled = ($block->custom == 1);
62    +          }
63    +
64             }
65             else {
66    -          $enabled = ($block->custom == 1);
67    +          $enabled = TRUE;
68    +        }
69    +        if ($enabled) {
70    +          $enabled_blocks[] = $block;
71             }
72           }
73    -      else {
74    -        $enabled = TRUE;
75    -      }
76    +      cache_set($cache_key, 'cache_advcache_block', serialize($enabled_blocks));
77    +    }
78    
79    +    foreach ($enabled_blocks as $block) {
80           // Match path if necessary
81           if ($block->pages) {
82             if ($block->visibility < 2) {
83    @@ -686,7 +702,7 @@
84             $page_match = TRUE;
85           }
86    
87    -      if ($enabled && $page_match) {
88    +      if ($page_match) {
89             // Check the current throttle status and see if block should be displayed
90             // based on server load.
91             if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.3