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

Diff of /contributions/modules/advcache/DRUPAL-5-8/all_files.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 21:39:28 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))) {
90    Index: modules/comment/comment.module
91    ===================================================================
92    RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
93    retrieving revision 1.520.2.12
94    diff -u -p -r1.520.2.12 comment.module
95    --- modules/comment/comment.module      7 Nov 2007 08:03:30 -0000       1.520.2.12
96    +++ modules/comment/comment.module      18 Jul 2008 21:05:06 -0000
97    @@ -931,6 +931,16 @@ function comment_links($comment, $return
98     function comment_render($node, $cid = 0) {
99       global $user;
100    
101    +  // If this is an authenticated user who only has one role and cannot admin-
102    +  // ister comments, look for a cached copy of the comment, or in the case
103    +  // of $cid = 0, the whole tree of comments.
104    +  $cache_key = 0;
105    +  if (!user_access('administer comments') && count($user->roles) === 1 && in_array('authenticated user', $user->roles)) {
106    +    // Must accommodate pagination
107    +    $page = isset($_GET['page']) ? $_GET['page'] : '';
108    +    $cache_key = 'nid-'. $node->nid. '::cid-'. $cid. '::'. $page;
109    +  }
110    +
111       $output = '';
112    
113       if (user_access('access comments')) {
114    @@ -945,6 +955,12 @@ function comment_render($node, $cid = 0)
115         $comments_per_page = _comment_get_display_setting('comments_per_page');
116    
117         if ($cid) {
118    +      if ($cache_key) {
119    +        $cache = cache_get($cache_key, 'cache_comment');
120    +        $comment = unserialize($cache->data);
121    +      }
122    +
123    +      if (!$comment) {
124           // Single comment view.
125           $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';
126           $query_args = array($cid);
127    @@ -963,11 +979,26 @@ function comment_render($node, $cid = 0)
128               $function = $module .'_link_alter';
129               $function($node, $links);
130             }
131    +        }
132    +      }
133    
134    +      if ($comment) {
135             $output .= theme('comment_view', $comment, $links);
136           }
137         }
138         else {
139    +      if ($cache_key) {
140    +        if ($cache = cache_get($cache_key, 'cache_comment')) {
141    +          $comments = unserialize($cache->data);
142    +          $comment_count = count($comments);
143    +
144    +          // Get the pager
145    +          $cache = cache_get($cache_key. '::pager', 'cache_comment');
146    +          $pager = $cache->data;
147    +        }
148    +      }
149    +
150    +      if (empty($comments)) {
151           // Multiple comment view
152           $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d';
153           $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
154    @@ -1002,21 +1033,32 @@ function comment_render($node, $cid = 0)
155               $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
156             }
157           }
158    -
159           // Start a form, for use with comment control.
160           $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
161    -      if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
162    +        $comment_count = db_num_rows($result);
163    +      }
164    +
165    +
166    +      if ($comment_count && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
167             $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
168           }
169    
170           $divs = 0;
171           $last_depth = 0;
172           drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
173    +
174    +      if (empty($comments)) {
175    +        $comments = array();
176           while ($comment = db_fetch_object($result)) {
177             $comment = drupal_unpack($comment);
178             $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
179             $comment->depth = count(explode('.', $comment->thread)) - 1;
180    +          $comments[] = $comment;
181    +        }
182    +        cache_set($cache_key, 'cache_comment', serialize($comments));
183    +      }
184    
185    +      foreach ($comments as $comment) {
186             if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
187               if ($comment->depth > $last_depth) {
188                 $divs++;
189    @@ -1048,9 +1090,15 @@ function comment_render($node, $cid = 0)
190           for ($i = 0; $i < $divs; $i++) {
191             $output .= '</div>';
192           }
193    -      $output .= theme('pager', NULL, $comments_per_page, 0);
194    
195    -      if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
196    +      if (empty($pager)) {
197    +        $pager = theme('pager', NULL, $comments_per_page, 0);
198    +        cache_set($cache_key. '::pager', 'cache_comment', $pager);
199    +      }
200    +
201    +      $output .= $pager;
202    +
203    +      if ($comment_count && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
204             $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
205           }
206         }
207    @@ -2012,4 +2060,3 @@ function int2vancode($i = 0) {
208     function vancode2int($c = '00') {
209       return base_convert(substr($c, 1), 36, 10);
210     }
211    -
212    Index: modules/node/node.module
213    ===================================================================
214    RCS file: /cvs/drupal/drupal/modules/node/node.module,v
215    retrieving revision 1.776.2.22
216    diff -u -p -r1.776.2.22 node.module
217    --- modules/node/node.module    7 Jan 2008 01:31:26 -0000       1.776.2.22
218    +++ modules/node/node.module    18 Jul 2008 21:05:07 -0000
219    @@ -2465,7 +2465,7 @@ function node_page_default($arg = NULL)
220     /**
221      * Menu callback; view a single node.
222      */
223    -function node_page_view($node, $cid = NULL) {
224    +function node_page_view($node, $cid = 0) {
225       drupal_set_title(check_plain($node->title));
226       return node_show($node, $cid);
227     }
228    ? sites/all/modules
229    Index: modules/node/node.module
230    ===================================================================
231    RCS file: /cvs/drupal/drupal/modules/node/node.module,v
232    retrieving revision 1.776.2.28
233    diff -u -p -r1.776.2.28 node.module
234    --- modules/node/node.module    7 Jun 2008 00:52:54 -0000       1.776.2.28
235    +++ modules/node/node.module    18 Jul 2008 21:31:03 -0000
236    @@ -541,17 +541,31 @@ function node_invoke_nodeapi(&$node, $op
237      *   A fully-populated node object.
238      */
239     function node_load($param = array(), $revision = NULL, $reset = NULL) {
240    +  global $user;
241       static $nodes = array();
242    
243       if ($reset) {
244         $nodes = array();
245       }
246    
247    -  $cachable = ($revision == NULL);
248    +  $cache_id = 0;
249       $arguments = array();
250       if (is_numeric($param)) {
251    -    if ($cachable && isset($nodes[$param])) {
252    -      return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
253    +    if (module_exists('advcache')) {
254    +      $cache_id = ($revision == NULL) ? $param. '::'. advcache_array2int($user->roles) : 0;
255    +    }
256    +    if ($cache_id > 0) {
257    +      if (isset($nodes[$param])) {
258    +        return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
259    +      }
260    +      if ($user->uid != 1) {
261    +        $cache = cache_get($cache_id, 'cache_node');
262    +        if ($cache) {
263    +          $cache = unserialize($cache->data);
264    +          $nodes[$param] = is_object($cache) ? drupal_clone($cache) : $cache;
265    +          return $nodes[$param];
266    +        }
267    +      }
268         }
269         $cond = 'n.nid = %d';
270         $arguments[] = $param;
271    @@ -589,8 +603,13 @@ function node_load($param = array(), $re
272             $node->$key = $value;
273           }
274         }
275    -    if ($cachable) {
276    +    if ($cache_id > 0) {
277           $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
278    +      if ($user->uid != 1) {
279    +        if (!in_array($node->type, variable_get('advcache_node_exclude_types', array('poll')))) {
280    +          cache_set($cache_id, 'cache_node', serialize($nodes[$node->nid]));
281    +        }
282    +      }
283         }
284       }
285    
286    @@ -2015,8 +2034,8 @@ function node_validate($node, $form = ar
287       if (isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
288         form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
289       }
290    -
291    -  if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
292    +  $changed = node_last_changed($node->nid);
293    +  if (isset($node->nid) && ($changed > $node->changed)) {
294         form_set_error('changed', t('This content has been modified by another user, changes cannot be saved.'));
295       }
296    
297    ? sites/all/modules
298    Index: modules/taxonomy/taxonomy.module
299    ===================================================================
300    RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
301    retrieving revision 1.330.2.17
302    diff -u -p -r1.330.2.17 taxonomy.module
303    --- modules/taxonomy/taxonomy.module    6 Jul 2008 00:50:44 -0000       1.330.2.17
304    +++ modules/taxonomy/taxonomy.module    18 Jul 2008 21:35:10 -0000
305    @@ -780,12 +780,25 @@ function taxonomy_node_get_terms($nid, $
306       static $terms;
307    
308       if (!isset($terms[$nid][$key])) {
309    -    $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid);
310    -    $terms[$nid][$key] = array();
311    -    while ($term = db_fetch_object($result)) {
312    -      $terms[$nid][$key][$term->$key] = $term;
313    +    // This caching breaks taxonomy access! The results of db_rewrite_sql will
314    +    // be cached, meaning the first user to load this node after a cache
315    +    // refresh will set the permissions for everyone. If you are using a module
316    +    // that does query rewriting on taxonomy queries, don't use this patch.
317    +    // If you're not sure whether or not this is the case, don't use this patch!
318    +    $cache_key = 'node::'. $nid. '::'. $key;
319    +    if ($cache = cache_get($cache_key, 'cache_taxonomy')) {
320    +      $terms[$nid][$key] = unserialize($cache->data);
321    +    }
322    +    else {
323    +      $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $nid);
324    +      $terms[$nid][$key] = array();
325    +      while ($term = db_fetch_object($result)) {
326    +        $terms[$nid][$key][$term->$key] = $term;
327    +      }
328    +      cache_set($cache_key, 'cache_taxonomy', serialize($terms[$nid][$key]));
329         }
330       }
331    +
332       return $terms[$nid][$key];
333     }
334    
335    @@ -989,7 +1002,14 @@ function taxonomy_get_children($tid, $vi
336      */
337     function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
338       static $children, $parents, $terms;
339    -
340    +  if ((0 === $parent) && (-1 === $depth)) {
341    +    if ($cache = cache_get('tree::'. $vid, 'cache_taxonomy')) {
342    +      return unserialize($cache->data);
343    +    }
344    +    else {
345    +      $cache_tree = TRUE;
346    +    }
347    +  }
348       $depth++;
349    
350       // We cache trees, so it's not CPU-intensive to call get_tree() on a term
351    @@ -1023,6 +1043,10 @@ function taxonomy_get_tree($vid, $parent
352         }
353       }
354    
355    +  if ($cache_tree) {
356    +    cache_set('tree::'. $vid, 'cache_taxonomy', serialize($tree));
357    +  }
358    +
359       return $tree ? $tree : array();
360     }
361    
362    @@ -1146,13 +1170,19 @@ function taxonomy_get_vocabulary($vid) {
363       static $vocabularies = array();
364    
365       if (!array_key_exists($vid, $vocabularies)) {
366    -    $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
367    -    $node_types = array();
368    -    while ($voc = db_fetch_object($result)) {
369    -      $node_types[] = $voc->type;
370    -      unset($voc->type);
371    -      $voc->nodes = $node_types;
372    -      $vocabularies[$vid] = $voc;
373    +    if ($cache = cache_get('vocabulary::'. $vid, 'cache_taxonomy')) {
374    +      $vocabularies[$vid] = unserialize($cache->data);
375    +    }
376    +    else {
377    +      $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d ORDER BY v.weight, v.name', $vid);
378    +      $node_types = array();
379    +      while ($voc = db_fetch_object($result)) {
380    +        $node_types[] = $voc->type;
381    +        unset($voc->type);
382    +        $voc->nodes = $node_types;
383    +        $vocabularies[$vid] = $voc;
384    +        cache_set('vocabulary::'. $vid, 'cache_taxonomy', serialize($voc));
385    +      }
386         }
387       }
388    
389    @@ -1172,7 +1202,13 @@ function taxonomy_get_term($tid) {
390       static $terms = array();
391    
392       if (!isset($terms[$tid])) {
393    -    $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
394    +    if ($cache = cache_get('term::'. $tid, 'cache_taxonomy')) {
395    +      $terms[$tid] = unserialize($cache->data);
396    +    }
397    +    else {
398    +      $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
399    +      cache_set('term::'. $tid, 'cache_taxonomy', serialize($terms[$tid]));
400    +    }
401       }
402    
403       return $terms[$tid];
404    @@ -1301,8 +1337,8 @@ function taxonomy_render_nodes($result)
405     function taxonomy_nodeapi($node, $op, $arg = 0) {
406       switch ($op) {
407         case 'load':
408    -     $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
409    -     return $output;
410    +      $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
411    +      return $output;
412         case 'insert':
413           taxonomy_node_save($node->nid, $node->taxonomy);
414           break;

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

  ViewVC Help
Powered by ViewVC 1.1.3