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

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

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

revision 1.1 by robertDouglass, Wed Sep 24 16:08:37 2008 UTC revision 1.2 by mikejoconnor, Thu Feb 26 13:39:13 2009 UTC
# Line 0  Line 1 
1    --- modules/block/block.module  2008-05-13 07:51:04.000000000 +0300
2    +++ modules/block/block.module.new      2008-07-20 16:08:57.100166595 +0300
3    @@ -286,6 +286,7 @@
4       }
5       drupal_set_message(t('The block settings have been updated.'));
6       cache_clear_all();
7    +  cache_clear_all('*', 'cache_advcache_block', TRUE);
8     }
9    
10     /**
11    @@ -500,6 +501,7 @@
12         module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values);
13         drupal_set_message(t('The block configuration has been saved.'));
14         cache_clear_all();
15    +    cache_clear_all('*', 'cache_advcache_block', TRUE);
16         return 'admin/build/block';
17       }
18     }
19    @@ -538,6 +540,7 @@
20       db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_values['bid']);
21       drupal_set_message(t('The block %name has been removed.', array('%name' => $form_values['info'])));
22       cache_clear_all();
23    +  cache_clear_all('*', 'cache_advcache_block', TRUE);
24       return 'admin/build/block';
25     };
26    
27    @@ -642,25 +645,38 @@
28       static $blocks = array();
29    
30       if (!count($blocks)) {
31    -    $rids = array_keys($user->roles);
32    -    $placeholders = implode(',', array_fill(0, count($rids), '%d'));
33    -    $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));
34    -    while ($block = db_fetch_object($result)) {
35    -      if (!isset($blocks[$block->region])) {
36    -        $blocks[$block->region] = array();
37    -      }
38    -      // Use the user's block visibility setting, if necessary
39    -      if ($block->custom != 0) {
40    -        if ($user->uid && isset($user->block[$block->module][$block->delta])) {
41    -          $enabled = $user->block[$block->module][$block->delta];
42    +    $cache_key = $user->uid. '::'. $theme_key;
43    +    $cache = cache_get($cache_key, 'cache_advcache_block');
44    +    $enabled_blocks = unserialize($cache->data);
45    +    if (empty($enabled_blocks)) {
46    +      $enabled_blocks = array();
47    +      $rids = array_keys($user->roles);
48    +      $placeholders = implode(',', array_fill(0, count($rids), '%d'));
49    +      $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));
50    +      while ($block = db_fetch_object($result)) {
51    +        if (!isset($blocks[$block->region])) {
52    +          $blocks[$block->region] = array();
53    +        }
54    +        // Use the user's block visibility setting, if necessary
55    +        if ($block->custom != 0) {
56    +          if ($user->uid && isset($user->block[$block->module][$block->delta])) {
57    +            $enabled = $user->block[$block->module][$block->delta];
58    +          }
59    +          else {
60    +            $enabled = ($block->custom == 1);
61    +          }
62             }
63             else {
64    -          $enabled = ($block->custom == 1);
65    +          $enabled = TRUE;
66    +        }
67    +        if ($enabled) {
68    +          $enabled_blocks[] = $block;
69             }
70           }
71    -      else {
72    -        $enabled = TRUE;
73    -      }
74    +      cache_set($cache_key, 'cache_advcache_block', serialize($enabled_blocks));
75    +    }
76    +
77    +    foreach ($enabled_blocks as $block) {
78    
79           // Match path if necessary
80           if ($block->pages) {
81    @@ -700,7 +716,7 @@
82         if (!isset($block->content)) {
83           // Erase the block from the static array - we'll put it back if it has content.
84           unset($blocks[$region][$key]);
85    -      if ($block->enabled && $block->page_match) {
86    +      if ($block->page_match) {
87             // Check the current throttle status and see if block should be displayed
88             // based on server load.
89             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