Commit ede6fb27 authored by robertDouglass's avatar robertDouglass
Browse files

getting rid of patch files. These will mostly live in a different module.

parent a29264c6
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.145
diff -u -F^f -r1.145 bootstrap.inc
--- includes/bootstrap.inc 15 Jan 2007 11:52:02 -0000 1.145
+++ includes/bootstrap.inc 24 Jan 2007 19:32:59 -0000
@@ -806,6 +806,7 @@ function _drupal_bootstrap($phase) {
break;
case DRUPAL_BOOTSTRAP_SESSION:
+ require_once './includes/memcache.inc';
require_once variable_get('session_inc', './includes/session.inc');
session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy_sid', 'sess_gc');
session_start();
@@ -875,6 +876,7 @@ function _drupal_cache_init($phase) {
*/
function drupal_maintenance_theme() {
global $theme;
+ require_once './includes/memcache.inc';
require_once './includes/path.inc';
require_once './includes/theme.inc';
require_once './includes/common.inc';
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.774
diff -u -r1.774 node.module
--- modules/node/node.module 11 Jan 2007 08:51:31 -0000 1.774
+++ modules/node/node.module 12 Jan 2007 22:59:32 -0000
@@ -484,17 +484,28 @@
* A fully-populated node object.
*/
function node_load($param = array(), $revision = NULL, $reset = NULL) {
+ global $user;
static $nodes = array();
if ($reset) {
+ foreach ($nodes as $node) {
+ dmemcache_delete($node->nid, 'node');
+ }
$nodes = array();
}
$cachable = ($revision == NULL);
$arguments = array();
if (is_numeric($param)) {
- if ($cachable && isset($nodes[$param])) {
- return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
+ if ($cachable) {
+ if (isset($nodes[$param])) {
+ return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
+ }
+ $cached_node = dmemcache_get($param, 'node');
+ if ($cached_node && $cached_node->nid) {
+ $nodes[$param] = is_object($cached_node) ? drupal_clone($cached_node) : $cached_node;
+ return $nodes[$param];
+ }
}
$cond = 'n.nid = %d';
$arguments[] = $param;
@@ -532,8 +543,12 @@
$node->$key = $value;
}
}
+
if ($cachable) {
$nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
+ if (is_numeric($param) && count($user->roles) === 1 && in_array('authenticated user', $user->roles)) {
+ dmemcache_set($param, $nodes[$node->nid], 0, 'node');
+ }
}
}
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.13
diff -u -r1.13 path.inc
--- includes/path.inc 23 Dec 2006 22:04:52 -0000 1.13
+++ includes/path.inc 13 Jan 2007 21:58:16 -0000
@@ -52,14 +52,30 @@
if ($action == 'wipe') {
$map = array();
$no_src = array();
+ dmemcache_flush('alias');
+ dmemcache_flush('src');
}
elseif ($count > 0 && $path != '') {
if ($action == 'alias') {
+ // static cache
if (isset($map[$path])) {
return $map[$path];
}
+ // memcache
+ if ($alias = dmemcache_get($path, 'alias')) {
+ $map[$path] = $alias['value'];
+ return $alias['value'];
+ }
+ // database
$alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path));
$map[$path] = $alias;
+ if (!$alias) {
+ $mc_value = array('value' => $alias);
+ dmemcache_set($path, $mc_value, 300, 'alias');
+ }
+ else {
+ dmemcache_set($path, array('value' => $alias), 300, 'alias');
+ }
return $alias;
}
// Check $no_src for this $path in case we've already determined that there
@@ -67,9 +83,14 @@
elseif ($action == 'source' && !isset($no_src[$path])) {
// Look for the value $path within the cached $map
if (!$src = array_search($path, $map)) {
- if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
+ if ($mc_src = dmemcache_get($path, 'src')) {
+ $src = $mc_src['value'];
$map[$src] = $path;
}
+ else if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
+ $map[$src] = $path;
+ dmemcache_set($path, array('value' => $src), 300, 'src');
+ }
else {
// We can't record anything into $map because we do not have a valid
// index and there is no need because we have not learned anything
@@ -77,6 +98,7 @@
$no_src[$path] = TRUE;
}
}
+
return $src;
}
}
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.105
diff -u -r1.105 path.module
--- modules/path/path.module 9 Jan 2007 08:34:03 -0000 1.105
+++ modules/path/path.module 13 Jan 2007 21:58:16 -0000
@@ -118,6 +118,8 @@
* Post-confirmation; delete an URL alias.
*/
function path_admin_delete($pid = 0) {
+ dmemcache_flush('src');
+ dmemcache_flush('alias');
db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid);
drupal_set_message(t('The alias has been deleted.'));
}
@@ -128,6 +130,9 @@
* Set an aliased path for a given Drupal path, preventing duplicates.
*/
function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) {
+ dmemcache_flush('src');
+ dmemcache_flush('alias');
+
if ($path && !$alias) {
db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path);
drupal_clear_path_cache();
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.745
diff -u -r1.745 user.module
--- modules/user/user.module 11 Jan 2007 08:52:45 -0000 1.745
+++ modules/user/user.module 13 Jan 2007 18:43:48 -0000
@@ -82,6 +82,8 @@
$user->roles[$role->rid] = $role->name;
}
user_module_invoke('load', $array, $user);
+
+ $user->access = dmemcache_get($user->uid, 'user_access');
}
else {
$user = FALSE;
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.330
diff -u -r1.330 taxonomy.module
--- modules/taxonomy/taxonomy.module 11 Jan 2007 03:29:15 -0000 1.330
+++ modules/taxonomy/taxonomy.module 12 Jan 2007 22:16:29 -0000
@@ -967,6 +967,13 @@
function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
static $children, $parents, $terms;
+ if ((0 === $parent) && (-1 === $depth) && $mc_tree = dmemcache_get($vid, 'taxonomy_get_tree')) {
+ return $mc_tree;
+ }
+ else {
+ $cache_tree = TRUE;
+ }
+
$depth++;
// We cache trees, so it's not CPU-intensive to call get_tree() on a term
@@ -1000,6 +1007,10 @@
}
}
+ if ($cache_tree) {
+ dmemcache_set($vid, $tree, 0, 'taxonomy_get_tree');
+ }
+
return $tree ? $tree : array();
}
@@ -1121,14 +1132,21 @@
function taxonomy_get_vocabulary($vid) {
static $vocabularies = array();
+
if (!array_key_exists($vid, $vocabularies)) {
- $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);
- $node_types = array();
- while ($voc = db_fetch_object($result)) {
- $node_types[] = $voc->type;
- unset($voc->type);
- $voc->nodes = $node_types;
- $vocabularies[$vid] = $voc;
+ if ($vocabulary = dmemcache_get($vid, 'vocabulary')) {
+ $vocabularies[$vid] = $vocabulary;
+ }
+ else {
+ $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);
+ $node_types = array();
+ while ($voc = db_fetch_object($result)) {
+ $node_types[] = $voc->type;
+ unset($voc->type);
+ $voc->nodes = $node_types;
+ $vocabularies[$vid] = $voc;
+ dmemcache_set($vid, $voc, 0, 'vocabulary');
+ }
}
}
@@ -1148,7 +1166,13 @@
static $terms = array();
if (!isset($terms[$tid])) {
- $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
+ if ($term = dmemcache_get($tid, 'term')) {
+ $terms[$tid] = $term;
+ }
+ else {
+ $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
+ dmemcache_set($tid, $terms[$tid], 0, 'term');
+ }
}
return $terms[$tid];
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment