| 1 |
|
Index: modules/node/node.module |
| 2 |
|
=================================================================== |
| 3 |
|
RCS file: /cvs/drupal/drupal/modules/node/node.module,v |
| 4 |
|
retrieving revision 1.776.2.22 |
| 5 |
|
diff -u -p -r1.776.2.22 node.module |
| 6 |
|
--- modules/node/node.module 7 Jan 2008 01:31:26 -0000 1.776.2.22 |
| 7 |
|
+++ modules/node/node.module 12 Oct 2008 10:36:09 -0000 |
| 8 |
|
@@ -501,17 +501,31 @@ function node_invoke_nodeapi(&$node, $op |
| 9 |
|
* A fully-populated node object. |
| 10 |
|
*/ |
| 11 |
|
function node_load($param = array(), $revision = NULL, $reset = NULL) { |
| 12 |
|
+ global $user; |
| 13 |
|
static $nodes = array(); |
| 14 |
|
|
| 15 |
|
if ($reset) { |
| 16 |
|
$nodes = array(); |
| 17 |
|
} |
| 18 |
|
|
| 19 |
|
- $cachable = ($revision == NULL); |
| 20 |
|
+ $cache_id = 0; |
| 21 |
|
$arguments = array(); |
| 22 |
|
if (is_numeric($param)) { |
| 23 |
|
- if ($cachable && isset($nodes[$param])) { |
| 24 |
|
- return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param]; |
| 25 |
|
+ if (module_exists('advcache')) { |
| 26 |
|
+ $cache_id = ($revision == NULL) ? "node/{$param}" : 0; |
| 27 |
|
+ } |
| 28 |
|
+ if ($cache_id !== 0) { |
| 29 |
|
+ if (isset($nodes[$param])) { |
| 30 |
|
+ return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param]; |
| 31 |
|
+ } |
| 32 |
|
+ if ($user->uid != 1) { |
| 33 |
|
+ $cache = cache_get($cache_id, 'cache_node'); |
| 34 |
|
+ if ($cache) { |
| 35 |
|
+ $cache = unserialize($cache->data); |
| 36 |
|
+ $nodes[$param] = is_object($cache) ? drupal_clone($cache) : $cache; |
| 37 |
|
+ return $nodes[$param]; |
| 38 |
|
+ } |
| 39 |
|
+ } |
| 40 |
|
} |
| 41 |
|
$cond = 'n.nid = %d'; |
| 42 |
|
$arguments[] = $param; |
| 43 |
|
@@ -549,8 +563,13 @@ function node_load($param = array(), $re |
| 44 |
|
$node->$key = $value; |
| 45 |
|
} |
| 46 |
|
} |
| 47 |
|
- if ($cachable) { |
| 48 |
|
+ if ($cache_id !== 0) { |
| 49 |
|
$nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node; |
| 50 |
|
+ if ($user->uid != 1) { |
| 51 |
|
+ if (!in_array($node->type, variable_get('advcache_node_exclude_types', array('poll')))) { |
| 52 |
|
+ cache_set($cache_id, 'cache_node', serialize($nodes[$node->nid])); |
| 53 |
|
+ } |
| 54 |
|
+ } |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
@@ -1975,8 +1994,8 @@ function node_validate($node, $form = ar |
| 59 |
|
if (isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) { |
| 60 |
|
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))); |
| 61 |
|
} |
| 62 |
|
- |
| 63 |
|
- if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) { |
| 64 |
|
+ $changed = node_last_changed($node->nid); |
| 65 |
|
+ if (isset($node->nid) && ($changed > $node->changed)) { |
| 66 |
|
form_set_error('changed', t('This content has been modified by another user, changes cannot be saved.')); |
| 67 |
|
} |
| 68 |
|
|