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

Diff of /contributions/modules/advcache/DRUPAL-5-7/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:11:44 2008 UTC revision 1.2 by mikejoconnor, Thu Feb 26 13:39:13 2009 UTC
# Line 0  Line 1 
1    ? sites/all/modules
2    Index: modules/block/block.module
3    ===================================================================
4    RCS file: /cvs/drupal/drupal/modules/block/block.module,v
5    retrieving revision 1.246.2.6
6    diff -u -p -r1.246.2.6 block.module
7    --- modules/block/block.module  12 Sep 2007 07:49:35 -0000      1.246.2.6
8    +++ modules/block/block.module  18 Jul 2008 21:11:12 -0000
9    @@ -286,6 +286,7 @@ function block_admin_display_submit($for
10       }
11       drupal_set_message(t('The block settings have been updated.'));
12       cache_clear_all();
13    +  cache_clear_all('*', 'cache_advcache_block', TRUE);
14     }
15    
16     /**
17    @@ -500,6 +501,7 @@ function block_admin_configure_submit($f
18         module_invoke($form_values['module'], 'block', 'save', $form_values['delta'], $form_values);
19         drupal_set_message(t('The block configuration has been saved.'));
20         cache_clear_all();
21    +    cache_clear_all('*', 'cache_advcache_block', TRUE);
22         return 'admin/build/block';
23       }
24     }
25    @@ -538,6 +540,7 @@ function block_box_delete_submit($form_i
26       db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_values['bid']);
27       drupal_set_message(t('The block %name has been removed.', array('%name' => $form_values['info'])));
28       cache_clear_all();
29    +  cache_clear_all('*', 'cache_advcache_block', TRUE);
30       return 'admin/build/block';
31     };
32    
33    @@ -643,26 +646,39 @@ function block_list($region) {
34       static $blocks = array();
35    
36       if (!count($blocks)) {
37    -    $rids = array_keys($user->roles);
38    -    $placeholders = implode(',', array_fill(0, count($rids), '%d'));
39    -    $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));
40    -    while ($block = db_fetch_object($result)) {
41    -      if (!isset($blocks[$block->region])) {
42    -        $blocks[$block->region] = array();
43    -      }
44    -      // Use the user's block visibility setting, if necessary
45    -      if ($block->custom != 0) {
46    -        if ($user->uid && isset($user->block[$block->module][$block->delta])) {
47    -          $enabled = $user->block[$block->module][$block->delta];
48    +    $cache_key = $user->uid. '::'. $theme_key;
49    +    $cache = cache_get($cache_key, 'cache_advcache_block');
50    +    $enabled_blocks = unserialize($cache->data);
51    +    if (empty($enabled_blocks)) {
52    +      $enabled_blocks = array();
53    +      $rids = array_keys($user->roles);
54    +      $placeholders = implode(',', array_fill(0, count($rids), '%d'));
55    +      $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));
56    +      while ($block = db_fetch_object($result)) {
57    +        if (!isset($blocks[$block->region])) {
58    +          $blocks[$block->region] = array();
59    +        }
60    +        // Use the user's block visibility setting, if necessary
61    +        if ($block->custom != 0) {
62    +          if ($user->uid && isset($user->block[$block->module][$block->delta])) {
63    +            $enabled = $user->block[$block->module][$block->delta];
64    +          }
65    +          else {
66    +            $enabled = ($block->custom == 1);
67    +          }
68    +
69             }
70             else {
71    -          $enabled = ($block->custom == 1);
72    +          $enabled = TRUE;
73    +        }
74    +        if ($enabled) {
75    +          $enabled_blocks[] = $block;
76             }
77           }
78    -      else {
79    -        $enabled = TRUE;
80    -      }
81    +      cache_set($cache_key, 'cache_advcache_block', serialize($enabled_blocks));
82    +    }
83    
84    +    foreach ($enabled_blocks as $block) {
85           // Match path if necessary
86           if ($block->pages) {
87             if ($block->visibility < 2) {
88    @@ -686,7 +702,7 @@ function block_list($region) {
89             $page_match = TRUE;
90           }
91    
92    -      if ($enabled && $page_match) {
93    +      if ($page_match) {
94             // Check the current throttle status and see if block should be displayed
95             // based on server load.
96             if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
97    Index: modules/comment/comment.module
98    ===================================================================
99    RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
100    retrieving revision 1.520.2.12
101    diff -u -p -r1.520.2.12 comment.module
102    --- modules/comment/comment.module      7 Nov 2007 08:03:30 -0000       1.520.2.12
103    +++ modules/comment/comment.module      18 Jul 2008 21:11:12 -0000
104    @@ -931,6 +931,16 @@ function comment_links($comment, $return
105     function comment_render($node, $cid = 0) {
106       global $user;
107    
108    +  // If this is an authenticated user who only has one role and cannot admin-
109    +  // ister comments, look for a cached copy of the comment, or in the case
110    +  // of $cid = 0, the whole tree of comments.
111    +  $cache_key = 0;
112    +  if (!user_access('administer comments') && count($user->roles) === 1 && in_array('authenticated user', $user->roles)) {
113    +    // Must accommodate pagination
114    +    $page = isset($_GET['page']) ? $_GET['page'] : '';
115    +    $cache_key = 'nid-'. $node->nid. '::cid-'. $cid. '::'. $page;
116    +  }
117    +
118       $output = '';
119    
120       if (user_access('access comments')) {
121    @@ -945,6 +955,12 @@ function comment_render($node, $cid = 0)
122         $comments_per_page = _comment_get_display_setting('comments_per_page');
123    
124         if ($cid) {
125    +      if ($cache_key) {
126    +        $cache = cache_get($cache_key, 'cache_comment');
127    +        $comment = unserialize($cache->data);
128    +      }
129    +
130    +      if (!$comment) {
131           // Single comment view.
132           $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';
133           $query_args = array($cid);
134    @@ -963,11 +979,26 @@ function comment_render($node, $cid = 0)
135               $function = $module .'_link_alter';
136               $function($node, $links);
137             }
138    +        }
139    +      }
140    
141    +      if ($comment) {
142             $output .= theme('comment_view', $comment, $links);
143           }
144         }
145         else {
146    +      if ($cache_key) {
147    +        if ($cache = cache_get($cache_key, 'cache_comment')) {
148    +          $comments = unserialize($cache->data);
149    +          $comment_count = count($comments);
150    +
151    +          // Get the pager
152    +          $cache = cache_get($cache_key. '::pager', 'cache_comment');
153    +          $pager = $cache->data;
154    +        }
155    +      }
156    +
157    +      if (empty($comments)) {
158           // Multiple comment view
159           $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d';
160           $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';
161    @@ -1002,21 +1033,32 @@ function comment_render($node, $cid = 0)
162               $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
163             }
164           }
165    -
166           // Start a form, for use with comment control.
167           $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
168    -      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)) {
169    +        $comment_count = db_num_rows($result);
170    +      }
171    +
172    +
173    +      if ($comment_count && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
174             $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
175           }
176    
177           $divs = 0;
178           $last_depth = 0;
179           drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
180    +
181    +      if (empty($comments)) {
182    +        $comments = array();
183           while ($comment = db_fetch_object($result)) {
184             $comment = drupal_unpack($comment);
185             $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
186             $comment->depth = count(explode('.', $comment->thread)) - 1;
187    +          $comments[] = $comment;
188    +        }
189    +        cache_set($cache_key, 'cache_comment', serialize($comments));
190    +      }
191    
192    +      foreach ($comments as $comment) {
193             if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
194               if ($comment->depth > $last_depth) {
195                 $divs++;
196    @@ -1048,9 +1090,15 @@ function comment_render($node, $cid = 0)
197           for ($i = 0; $i < $divs; $i++) {
198             $output .= '</div>';
199           }
200    -      $output .= theme('pager', NULL, $comments_per_page, 0);
201    
202    -      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)) {
203    +      if (empty($pager)) {
204    +        $pager = theme('pager', NULL, $comments_per_page, 0);
205    +        cache_set($cache_key. '::pager', 'cache_comment', $pager);
206    +      }
207    +
208    +      $output .= $pager;
209    +
210    +      if ($comment_count && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
211             $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
212           }
213         }
214    @@ -2012,4 +2060,3 @@ function int2vancode($i = 0) {
215     function vancode2int($c = '00') {
216       return base_convert(substr($c, 1), 36, 10);
217     }
218    -
219    Index: modules/node/node.module
220    ===================================================================
221    RCS file: /cvs/drupal/drupal/modules/node/node.module,v
222    retrieving revision 1.776.2.22
223    diff -u -p -r1.776.2.22 node.module
224    --- modules/node/node.module    7 Jan 2008 01:31:26 -0000       1.776.2.22
225    +++ modules/node/node.module    18 Jul 2008 21:11:13 -0000
226    @@ -501,17 +501,31 @@ function node_invoke_nodeapi(&$node, $op
227      *   A fully-populated node object.
228      */
229     function node_load($param = array(), $revision = NULL, $reset = NULL) {
230    +  global $user;
231       static $nodes = array();
232    
233       if ($reset) {
234         $nodes = array();
235       }
236    
237    -  $cachable = ($revision == NULL);
238    +  $cache_id = 0;
239       $arguments = array();
240       if (is_numeric($param)) {
241    -    if ($cachable && isset($nodes[$param])) {
242    -      return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
243    +    if (module_exists('advcache')) {
244    +      $cache_id = ($revision == NULL) ? $param. '::'. advcache_array2int($user->roles) : 0;
245    +    }
246    +    if ($cache_id > 0) {
247    +      if (isset($nodes[$param])) {
248    +        return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
249    +      }
250    +      if ($user->uid != 1) {
251    +        $cache = cache_get($cache_id, 'cache_node');
252    +        if ($cache) {
253    +          $cache = unserialize($cache->data);
254    +          $nodes[$param] = is_object($cache) ? drupal_clone($cache) : $cache;
255    +          return $nodes[$param];
256    +        }
257    +      }
258         }
259         $cond = 'n.nid = %d';
260         $arguments[] = $param;
261    @@ -549,8 +563,13 @@ function node_load($param = array(), $re
262             $node->$key = $value;
263           }
264         }
265    -    if ($cachable) {
266    +    if ($cache_id > 0) {
267           $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
268    +      if ($user->uid != 1) {
269    +        if (!in_array($node->type, variable_get('advcache_node_exclude_types', array('poll')))) {
270    +          cache_set($cache_id, 'cache_node', serialize($nodes[$node->nid]));
271    +        }
272    +      }
273         }
274       }
275    
276    @@ -1975,8 +1994,8 @@ function node_validate($node, $form = ar
277       if (isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
278         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)));
279       }
280    -
281    -  if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
282    +  $changed = node_last_changed($node->nid);
283    +  if (isset($node->nid) && ($changed > $node->changed)) {
284         form_set_error('changed', t('This content has been modified by another user, changes cannot be saved.'));
285       }
286    
287    @@ -2465,7 +2484,7 @@ function node_page_default($arg = NULL)
288     /**
289      * Menu callback; view a single node.
290      */
291    -function node_page_view($node, $cid = NULL) {
292    +function node_page_view($node, $cid = 0) {
293       drupal_set_title(check_plain($node->title));
294       return node_show($node, $cid);
295     }
296    Index: modules/taxonomy/taxonomy.module
297    ===================================================================
298    RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
299    retrieving revision 1.330.2.15
300    diff -u -p -r1.330.2.15 taxonomy.module
301    --- modules/taxonomy/taxonomy.module    20 Dec 2007 07:48:11 -0000      1.330.2.15
302    +++ modules/taxonomy/taxonomy.module    18 Jul 2008 21:11:14 -0000
303    @@ -780,12 +780,25 @@ function taxonomy_node_get_terms($nid, $
304       static $terms;
305    
306       if (!isset($terms[$nid][$key])) {
307    -    $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);
308    -    $terms[$nid][$key] = array();
309    -    while ($term = db_fetch_object($result)) {
310    -      $terms[$nid][$key][$term->$key] = $term;
311    +    // This caching breaks taxonomy access! The results of db_rewrite_sql will
312    +    // be cached, meaning the first user to load this node after a cache
313    +    // refresh will set the permissions for everyone. If you are using a module
314    +    // that does query rewriting on taxonomy queries, don't use this patch.
315    +    // If you're not sure whether or not this is the case, don't use this patch!
316    +    $cache_key = 'node::'. $nid. '::'. $key;
317    +    if ($cache = cache_get($cache_key, 'cache_taxonomy')) {
318    +      $terms[$nid][$key] = unserialize($cache->data);
319    +    }
320    +    else {
321    +      $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);
322    +      $terms[$nid][$key] = array();
323    +      while ($term = db_fetch_object($result)) {
324    +        $terms[$nid][$key][$term->$key] = $term;
325    +      }
326    +      cache_set($cache_key, 'cache_taxonomy', serialize($terms[$nid][$key]));
327         }
328       }
329    +
330       return $terms[$nid][$key];
331     }
332    
333    @@ -989,7 +1002,14 @@ function taxonomy_get_children($tid, $vi
334      */
335     function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
336       static $children, $parents, $terms;
337    -
338    +  if ((0 === $parent) && (-1 === $depth)) {
339    +    if ($cache = cache_get('tree::'. $vid, 'cache_taxonomy')) {
340    +      return unserialize($cache->data);
341    +    }
342    +    else {
343    +      $cache_tree = TRUE;
344    +    }
345    +  }
346       $depth++;
347    
348       // We cache trees, so it's not CPU-intensive to call get_tree() on a term
349    @@ -1023,6 +1043,10 @@ function taxonomy_get_tree($vid, $parent
350         }
351       }
352    
353    +  if ($cache_tree) {
354    +    cache_set('tree::'. $vid, 'cache_taxonomy', serialize($tree));
355    +  }
356    +
357       return $tree ? $tree : array();
358     }
359    
360    @@ -1145,13 +1169,19 @@ function taxonomy_get_vocabulary($vid) {
361       static $vocabularies = array();
362    
363       if (!array_key_exists($vid, $vocabularies)) {
364    -    $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);
365    -    $node_types = array();
366    -    while ($voc = db_fetch_object($result)) {
367    -      $node_types[] = $voc->type;
368    -      unset($voc->type);
369    -      $voc->nodes = $node_types;
370    -      $vocabularies[$vid] = $voc;
371    +    if ($cache = cache_get('vocabulary::'. $vid, 'cache_taxonomy')) {
372    +      $vocabularies[$vid] = unserialize($cache->data);
373    +    }
374    +    else {
375    +      $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);
376    +      $node_types = array();
377    +      while ($voc = db_fetch_object($result)) {
378    +        $node_types[] = $voc->type;
379    +        unset($voc->type);
380    +        $voc->nodes = $node_types;
381    +        $vocabularies[$vid] = $voc;
382    +        cache_set('vocabulary::'. $vid, 'cache_taxonomy', serialize($voc));
383    +      }
384         }
385       }
386    
387    @@ -1171,7 +1201,13 @@ function taxonomy_get_term($tid) {
388       static $terms = array();
389    
390       if (!isset($terms[$tid])) {
391    -    $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
392    +    if ($cache = cache_get('term::'. $tid, 'cache_taxonomy')) {
393    +      $terms[$tid] = unserialize($cache->data);
394    +    }
395    +    else {
396    +      $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
397    +      cache_set('term::'. $tid, 'cache_taxonomy', serialize($terms[$tid]));
398    +    }
399       }
400    
401       return $terms[$tid];
402    @@ -1300,8 +1336,8 @@ function taxonomy_render_nodes($result)
403     function taxonomy_nodeapi($node, $op, $arg = 0) {
404       switch ($op) {
405         case 'load':
406    -     $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
407    -     return $output;
408    +      $output['taxonomy'] = taxonomy_node_get_terms($node->nid);
409    +      return $output;
410         case 'insert':
411           taxonomy_node_save($node->nid, $node->taxonomy);
412           break;

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

  ViewVC Help
Powered by ViewVC 1.1.3