? .bzr
? .bzrignore
? bigint.patch
? bigint.patch.1
? patch
? sites/all/modules
? sites/default/config.php
? sites/default/files
? sites/default/settings.php
? sites/default/x.php
Index: includes/database.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.inc,v
retrieving revision 1.92.2.4
diff -u -p -r1.92.2.4 database.inc
--- includes/database.inc	16 Feb 2009 14:41:58 -0000	1.92.2.4
+++ includes/database.inc	29 Jul 2009 16:08:28 -0000
@@ -207,8 +207,21 @@ function _db_query_callback($match, $ini
   }
 
   switch ($match[1]) {
-    case '%d': // We must use type casting to int to convert FALSE/NULL/(TRUE?)
-      return (int) array_shift($args); // We don't need db_escape_string as numbers are db-safe
+    case '%d':
+      $value = array_shift($args);
+      // Do we need special bigint handling? This solution works for 53 bits.
+      if ($value > PHP_INT_MAX) {
+        $precision = ini_get('precision');
+        @ini_set('precision', 16);
+        $value = sprintf('%.0f', $value);
+        @ini_set('precision', $precision);
+      }
+      else {
+        // We must use type casting to int to convert FALSE/NULL/TRUE
+        $value = (int) $value;
+      }
+      // We don't need db_escape_string as numbers are db-safe.
+      return $value;
     case '%s':
       return db_escape_string(array_shift($args));
     case '%n':
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.255.2.28
diff -u -p -r1.255.2.28 menu.inc
--- includes/menu.inc	9 Feb 2009 16:28:21 -0000	1.255.2.28
+++ includes/menu.inc	29 Jul 2009 16:08:28 -0000
@@ -310,9 +310,22 @@ function menu_get_item($path = NULL, $ro
   if (!isset($router_items[$path])) {
     $original_map = arg(NULL, $path);
     $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
-    list($ancestors, $placeholders) = menu_get_ancestors($parts);
 
-    if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {
+    // Drupal memcache hack: cache the router items.
+    $cid = "item:$path";
+    $cache = cache_get($cid, 'cache_menu');
+    if ($cache) {
+      $router_item = $cache->data;
+    }
+    else {
+      list($ancestors, $placeholders) = menu_get_ancestors($parts);
+      $router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1));
+    }
+
+    if ($router_item) {
+      if (!$cache) {
+        cache_set($cid, $router_item, 'cache_menu');
+      }
       $map = _menu_translate($router_item, $original_map);
       if ($map === FALSE) {
         $router_items[$path] = FALSE;
@@ -575,7 +588,7 @@ function _menu_translate(&$router_item, 
   $router_item['href'] = implode('/', $link_map);
   $router_item['options'] = array();
   _menu_check_access($router_item, $map);
-  
+
   // For performance, don't localize an item the user can't access.
   if ($router_item['access']) {
     _menu_item_localize($router_item, $map);
@@ -1305,14 +1318,22 @@ function menu_local_tasks($level = 0, $r
     if (!$router_item || !$router_item['access']) {
       return '';
     }
+    // Drupal memcache hack: as most pages do not have tabs, we cache this information.
+    $cid = 'no_tasks:' . $router_item['path'];
+    if (cache_get($cid, 'cache_menu')) {
+      return '';
+    }
     // Get all tabs and the root page.
     $result = db_query("SELECT * FROM {menu_router} WHERE tab_root = '%s' ORDER BY weight, title", $router_item['tab_root']);
     $map = arg();
     $children = array();
     $tasks = array();
     $root_path = $router_item['path'];
+    // Drupal memcache hack: as most pages do not have tabs, we cache this information.
+    $count = 0;
 
     while ($item = db_fetch_array($result)) {
+      $count++;
       _menu_translate($item, $map, TRUE);
       if ($item['tab_parent']) {
         // All tabs, but not the root page.
@@ -1321,6 +1342,9 @@ function menu_local_tasks($level = 0, $r
       // Store the translated item for later use.
       $tasks[$item['path']] = $item;
     }
+    if ($count < 2) {
+      cache_set($cid, 1, 'cache_menu');
+    }
 
     // Find all tabs below the current path.
     $path = $router_item['path'];
@@ -1837,7 +1861,7 @@ function _menu_delete_item($item, $force
  *   - plid        The mlid of the parent.
  *   - router_path The path of the relevant router item.
  * @return
- *   The mlid of the saved menu link, or FALSE if the menu link could not be 
+ *   The mlid of the saved menu link, or FALSE if the menu link could not be
  *   saved.
  */
 function menu_link_save(&$item) {
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.115.2.1
diff -u -p -r1.115.2.1 module.inc
--- includes/module.inc	16 Feb 2009 10:32:10 -0000	1.115.2.1
+++ includes/module.inc	29 Jul 2009 16:08:28 -0000
@@ -57,12 +57,22 @@ function module_list($refresh = FALSE, $
       }
     }
     else {
+      // Drupal memcache hack: we cache the module list.
+      $cid = "module_list:$bootstrap";
+      if ($cache = cache_get($cid)) {
+        foreach ($cache->data['files'] as $name => $filename) {
+          drupal_get_filename('module', $name, $filename);
+        }
+        $list = $cache->data['modules'];
+        return $list;
+      }
       if ($bootstrap) {
         $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");
       }
       else {
         $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
       }
+      $data['files'] = array();
       while ($module = db_fetch_object($result)) {
         if (file_exists($module->filename)) {
           // Determine the current throttle status and see if the module should be
@@ -72,9 +82,14 @@ function module_list($refresh = FALSE, $
           if (!$throttle) {
             drupal_get_filename('module', $module->name, $module->filename);
             $list[$module->name] = $module->name;
+            // Drupal memcache hack: we cache the list.
+            $data['files'][$module->name] = $module->filename;
           }
         }
       }
+      // Drupal memcache hack: we cache the list.
+      $data['modules'] = $list;
+      cache_set($cid, $data);
     }
   }
   if ($sort) {
@@ -278,6 +293,15 @@ function module_load_all_includes($type,
 }
 
 /**
+ * Drupal memcache hack: clear the module list cache.
+ */
+function _module_clear_cache() {
+  foreach (array('module_list:1', 'module_list:', 'node_types') as $key) {
+    cache_clear_all($key, 'cache');
+  }
+}
+
+/**
  * Enable a given list of modules.
  *
  * @param $module_list
@@ -300,6 +324,7 @@ function module_enable($module_list) {
     module_list(TRUE, FALSE);
     // Force to regenerate the stored list of hook implementations.
     module_implements('', FALSE, TRUE);
+    _module_clear_cache();
   }
 
   foreach ($invoke_modules as $module) {
@@ -341,6 +366,7 @@ function module_disable($module_list) {
     module_list(TRUE, FALSE);
     // Force to regenerate the stored list of hook implementations.
     module_implements('', FALSE, TRUE);
+    _module_clear_cache();
   }
 
   // If there remains no more node_access module, rebuilding will be
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.19.2.1
diff -u -p -r1.19.2.1 path.inc
--- includes/path.inc	13 Oct 2008 21:06:41 -0000	1.19.2.1
+++ includes/path.inc	29 Jul 2009 16:08:28 -0000
@@ -47,6 +47,9 @@ function drupal_lookup_path($action, $pa
   global $language;
   // $map is an array with language keys, holding arrays of Drupal paths to alias relations
   static $map = array(), $no_src = array(), $count;
+  // Drupal memcache hack: we do not support the core path aliases. If you
+  // want aliasing, use programmed custom_url_rewrite_[in/out]bound.
+  return FALSE;
 
   $path_language = $path_language ? $path_language : $language->language;
 
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.415.2.18
diff -u -p -r1.415.2.18 theme.inc
--- includes/theme.inc	16 Feb 2009 12:00:11 -0000	1.415.2.18
+++ includes/theme.inc	29 Jul 2009 16:08:29 -0000
@@ -242,6 +242,9 @@ function _theme_save_registry($theme, $r
  */
 function drupal_rebuild_theme_registry() {
   cache_clear_all('theme_registry', 'cache', TRUE);
+  // Drupal memcache hack: cache enabled themes and regions.
+  cache_clear_all('themes', 'cache');
+  cache_clear_all('region_list', 'cache');
 }
 
 /**
@@ -446,12 +449,20 @@ function list_themes($refresh = FALSE) {
     // Extract from the database only when it is available.
     // Also check that the site is not in the middle of an install or update.
     if (db_is_active() && !defined('MAINTENANCE_MODE')) {
-      $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme');
-      while ($theme = db_fetch_object($result)) {
-        if (file_exists($theme->filename)) {
-          $theme->info = unserialize($theme->info);
-          $themes[] = $theme;
+      // Drupal memcache hack: cache enabled themes.
+      $cache = cache_get('themes');
+      if ($cache) {
+        $themes = $cache->data;
+      }
+      else {
+        $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme');
+        while ($theme = db_fetch_object($result)) {
+          if (file_exists($theme->filename)) {
+            $theme->info = unserialize($theme->info);
+            $themes[] = $theme;
+          }
         }
+        cache_set('themes', $themes);
       }
     }
     else {
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.299.2.3
diff -u -p -r1.299.2.3 block.module
--- modules/block/block.module	24 Jun 2008 14:40:08 -0000	1.299.2.3
+++ modules/block/block.module	29 Jul 2009 16:08:29 -0000
@@ -404,48 +404,22 @@ function block_list($region) {
 
   if (!count($blocks)) {
     $rids = array_keys($user->roles);
-    $result = db_query(db_rewrite_sql("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 (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
-    while ($block = db_fetch_object($result)) {
-      if (!isset($blocks[$block->region])) {
-        $blocks[$block->region] = array();
+    // Drupal memcache hack: we cache the block list.
+    $cid = "block_list:$theme_key:". implode(':', $rids);
+    $cache = cache_get($cid);
+    if ($cache) {
+      foreach ($cache->data as $block) {
+        $blocks = _block_list($block);
+      }
+    }
+    else {
+      $data = array();
+      $result = db_query(db_rewrite_sql("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 (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
+      while ($block = db_fetch_object($result)) {
+        $data[] = $block;
+        $blocks = _block_list($block);
       }
-      // Use the user's block visibility setting, if necessary
-      if ($block->custom != 0) {
-        if ($user->uid && isset($user->block[$block->module][$block->delta])) {
-          $enabled = $user->block[$block->module][$block->delta];
-        }
-        else {
-          $enabled = ($block->custom == 1);
-        }
-      }
-      else {
-        $enabled = TRUE;
-      }
-
-      // Match path if necessary
-      if ($block->pages) {
-        if ($block->visibility < 2) {
-          $path = drupal_get_path_alias($_GET['q']);
-          // Compare with the internal and path alias (if any).
-          $page_match = drupal_match_path($path, $block->pages);
-          if ($path != $_GET['q']) {
-            $page_match = $page_match || drupal_match_path($_GET['q'], $block->pages);
-          }
-          // When $block->visibility has a value of 0, the block is displayed on
-          // all pages except those listed in $block->pages. When set to 1, it
-          // is displayed only on those pages listed in $block->pages.
-          $page_match = !($block->visibility xor $page_match);
-        }
-        else {
-          $page_match = drupal_eval($block->pages);
-        }
-      }
-      else {
-        $page_match = TRUE;
-      }
-      $block->enabled = $enabled;
-      $block->page_match = $page_match;
-      $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
+      cache_set($cid, $data);
     }
   }
 
@@ -500,6 +474,56 @@ function block_list($region) {
 }
 
 /**
+ * Drupal memcache hack: we cache the block list and this is a helper.
+ */
+function _block_list($block) {
+  global $user;
+  static $blocks;
+
+  if (!isset($blocks[$block->region])) {
+    $blocks[$block->region] = array();
+  }
+  // Use the user's block visibility setting, if necessary
+  if ($block->custom != 0) {
+    if ($user->uid && isset($user->block[$block->module][$block->delta])) {
+      $enabled = $user->block[$block->module][$block->delta];
+    }
+    else {
+      $enabled = ($block->custom == 1);
+    }
+  }
+  else {
+    $enabled = TRUE;
+  }
+
+  // Match path if necessary
+  if ($block->pages) {
+    if ($block->visibility < 2) {
+      $path = drupal_get_path_alias($_GET['q']);
+      // Compare with the internal and path alias (if any).
+      $page_match = drupal_match_path($path, $block->pages);
+      if ($path != $_GET['q']) {
+        $page_match = $page_match || drupal_match_path($_GET['q'], $block->pages);
+      }
+      // When $block->visibility has a value of 0, the block is displayed on
+      // all pages except those listed in $block->pages. When set to 1, it
+      // is displayed only on those pages listed in $block->pages.
+      $page_match = !($block->visibility xor $page_match);
+    }
+    else {
+      $page_match = drupal_eval($block->pages);
+    }
+  }
+  else {
+    $page_match = TRUE;
+  }
+  $block->enabled = $enabled;
+  $block->page_match = $page_match;
+  $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
+  return $blocks;
+}
+
+/**
  * Assemble the cache_id to use for a given block.
  *
  * The cache_id string reflects the viewing context for the current block
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.947.2.15
diff -u -p -r1.947.2.15 node.module
--- modules/node/node.module	16 Feb 2009 14:39:40 -0000	1.947.2.15
+++ modules/node/node.module	29 Jul 2009 16:08:31 -0000
@@ -476,6 +476,8 @@ function node_types_rebuild() {
  *   Status flag indicating outcome of the operation.
  */
 function node_type_save($info) {
+  // Drupal memcache hack: we cache node types.
+  cache_clear_all('node_types', 'cache');
   $is_existing = FALSE;
   $existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
   $is_existing = db_result(db_query("SELECT COUNT(*) FROM {node_type} WHERE type = '%s'", $existing_type));
@@ -539,6 +541,11 @@ function node_type_update_nodes($old_typ
  *
  */
 function _node_types_build() {
+  // Drupal memcache hack: we cache node types.
+  $cid = 'node_types';
+  if ($cache = cache_get($cid)) {
+    return $cache->data;
+  }
   $_node_types = array();
   $_node_names = array();
 
@@ -569,6 +576,7 @@ function _node_types_build() {
   }
 
   asort($_node_names);
+  cache_set($cid, array($_node_types, $_node_names));
 
   return array($_node_types, $_node_names);
 }
@@ -1255,10 +1263,10 @@ function node_search($op = 'search', $ke
         $join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid';
         $total += $weight;
       }
-      
-      // When all search factors are disabled (ie they have a weight of zero), 
-      // the default score is based only on keyword relevance and there is no need to 
-      // adjust the score of each item. 
+
+      // When all search factors are disabled (ie they have a weight of zero),
+      // the default score is based only on keyword relevance and there is no need to
+      // adjust the score of each item.
       if ($total == 0) {
         $select2 = 'i.relevance AS score';
         $total = 1;
@@ -1266,7 +1274,7 @@ function node_search($op = 'search', $ke
       else {
         $select2 = implode(' + ', $ranking) . ' AS score';
       }
-      
+
       // Do search.
       $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. $join1, $conditions1 . (empty($where1) ? '' : ' AND '. $where1), $arguments1, $select2, $join2, $arguments2);
 
@@ -2030,6 +2038,9 @@ function node_access($op, $node, $accoun
     return $access;
   }
 
+  // Drupal memcache hack: we do not support node access modules.
+  return $op == 'view';
+
   // If the module did not override the access rights, use those set in the
   // node_access table.
   if ($op != 'create' && $node->nid && $node->status) {
@@ -2169,6 +2180,9 @@ function node_access_view_all_nodes() {
  * Implementation of hook_db_rewrite_sql
  */
 function node_db_rewrite_sql($query, $primary_table, $primary_field) {
+  // Drupal memcache hack: we do not support node access modules.
+  return;
+
   if ($primary_field == 'nid' && !node_access_view_all_nodes()) {
     $return['join'] = _node_access_join_sql($primary_table);
     $return['where'] = _node_access_where_sql();
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.63.2.6
diff -u -p -r1.63.2.6 system.admin.inc
--- modules/system/system.admin.inc	6 Jan 2009 13:33:24 -0000	1.63.2.6
+++ modules/system/system.admin.inc	29 Jul 2009 16:08:31 -0000
@@ -1726,7 +1726,7 @@ function system_run_cron() {
  * Menu callback: return information about PHP.
  */
 function system_php() {
-  phpinfo(INFO_GENERAL | INFO_CONFIGURATION);
+  phpinfo();
   exit();
 }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.585.2.31
diff -u -p -r1.585.2.31 system.module
--- modules/system/system.module	14 Jan 2009 23:54:01 -0000	1.585.2.31
+++ modules/system/system.module	29 Jul 2009 16:08:32 -0000
@@ -961,9 +961,15 @@ function system_find_base_theme($themes,
 function system_region_list($theme_key) {
   static $list = array();
 
+  // Drupal memcache hack: we cache regions.
+  $cid = 'region_list';
+  if ($cache = cache_get($cid)) {
+    $list += $cache->data;
+  }
   if (!array_key_exists($theme_key, $list)) {
     $info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key)));
     $list[$theme_key] = array_map('t', $info['regions']);
+    cache_set($cid, $list);
   }
 
   return $list[$theme_key];
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.892.2.11
diff -u -p -r1.892.2.11 user.module
--- modules/user/user.module	14 Jan 2009 23:34:08 -0000	1.892.2.11
+++ modules/user/user.module	29 Jul 2009 16:08:32 -0000
@@ -496,19 +496,28 @@ function user_access($string, $account =
     return TRUE;
   }
 
-  // To reduce the number of SQL queries, we cache the user's permissions
-  // in a static variable.
-  if (!isset($perm[$account->uid])) {
-    $result = db_query("SELECT p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (". db_placeholders($account->roles) .")", array_keys($account->roles));
-
-    $perms = array();
-    while ($row = db_fetch_object($result)) {
-      $perms += array_flip(explode(', ', $row->perm));
+  // Drupal memcache hack: we cache permissions.
+  if (empty($perm)) {
+    $permissions = cache_get('permissions');
+    if ($permissions) {
+      $perm = $permissions->data;
+    }
+    else {
+      $permissions = array();
+      $result = db_query('SELECT rid, perm FROM {permission}');
+      while ($permission = db_fetch_object($result)) {
+        $permissions[$permission->rid] = array_flip(explode(', ', $permission->perm));
+      }
+      cache_set('permissions', $permissions);
+      $perm = $permissions;
     }
-    $perm[$account->uid] = $perms;
   }
-
-  return isset($perm[$account->uid][$string]);
+  foreach ($account->roles as $rid => $name) {
+    if (isset($perm[$rid][$string])) {
+      return TRUE;
+    }
+  }
+  return FALSE;
 }
 
 /**
Index: themes/garland/garland.info
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/garland.info,v
retrieving revision 1.5
diff -u -p -r1.5 garland.info
--- themes/garland/garland.info	1 Jul 2007 23:27:32 -0000	1.5
+++ themes/garland/garland.info	29 Jul 2009 16:08:32 -0000
@@ -6,3 +6,9 @@ core = 6.x
 engine = phptemplate
 stylesheets[all][] = style.css
 stylesheets[print][] = print.css
+regions[left] = Left sidebar
+regions[right] = Right sidebar
+regions[content] = Content
+regions[header] = Header
+regions[footer] = Footer
+regions[boo] = bar
