--- includes/bootstrap.inc.orig	2011-12-05 23:18:55.000000000 +0100
+++ includes/bootstrap.inc	2012-01-24 11:46:30.000000000 +0100
@@ -289,12 +289,12 @@
   /**
    * A cid to pass to cache_set() and cache_get().
    */
-  private $cid;
+  protected $cid;
 
   /**
    * A bin to pass to cache_set() and cache_get().
    */
-  private $bin;
+  protected $bin;
 
   /**
    * An array of keys to add to the cache at the end of the request.
@@ -381,24 +381,20 @@
   /**
    * Immediately write a value to the persistent cache.
    *
-   * @param $cid
-   *   The cache ID.
-   * @param $bin
-   *   The cache bin.
    * @param $data
    *   The data to write to the persistent cache.
    * @param $lock
    *   Whether to acquire a lock before writing to cache.
    */
-  protected function set($cid, $data, $bin, $lock = TRUE) {
+  protected function set($data, $lock = TRUE) {
     // Lock cache writes to help avoid stampedes.
     // To implement locking for cache misses, override __construct().
-    $lock_name = $cid . ':' . $bin;
+    $lock_name = $this->cid . ':' . $this->bin;
     if (!$lock || lock_acquire($lock_name)) {
-      if ($cached = cache_get($cid, $bin)) {
+      if ($cached = cache_get($this->cid, $this->bin)) {
         $data = $cached->data + $data;
       }
-      cache_set($cid, $data, $bin);
+      cache_set($this->cid, $data, $this->bin);
       if ($lock) {
         lock_release($lock_name);
       }
@@ -413,7 +409,7 @@
       }
     }
     if (!empty($data)) {
-      $this->set($this->cid, $data, $this->bin);
+      $this->set($data);
     }
   }
 }
--- includes/common.inc.orig	2011-12-05 23:18:55.000000000 +0100
+++ includes/common.inc	2012-01-24 11:48:11.000000000 +0100
@@ -2338,7 +2338,7 @@
     // rendering.
     if (variable_get('theme_link', TRUE)) {
       drupal_theme_initialize();
-      $registry = theme_get_registry();
+      $registry = theme_get_registry(FALSE);
       // We don't want to duplicate functionality that's in theme(), so any
       // hint of a module or theme doing anything at all special with the 'link'
       // theme hook should simply result in theme() being called. This includes
--- includes/theme.inc.orig	2011-12-05 23:18:55.000000000 +0100
+++ includes/theme.inc	2012-01-24 11:56:25.000000000 +0100
@@ -372,23 +372,31 @@
       $data = $cached->data;
     }
     else {
-      $complete_registry = theme_get_registry();
       if ($this->persistable) {
         // If there is no runtime cache stored, fetch the full theme registry,
         // but then initialize each value to NULL. This allows
         // offsetExists() to function correctly on non-registered theme hooks
         // without triggering a call to resolveCacheMiss().
-        $data = array_fill_keys(array_keys($complete_registry), NULL);
-        $this->set($this->cid, $data, $this->bin);
-        $this->completeRegistry = $complete_registry;
-      }
-      else {
-        $data = $complete_registry;
+        $data = $this->initializeRegistry();
+        $this->set($data);
       }
     }
     $this->storage = $data;
   }
 
+  /**
+   * Initializes the full theme registry
+   *
+   * @return
+   *   An array with the keys of the full theme registry, but the values
+   *   initialized to NULL.
+   */
+  function initializeRegistry() {
+    $this->completeRegistry = theme_get_registry();
+
+	return array_fill_keys(array_keys($this->completeRegistry), NULL);
+  }
+
   public function offsetExists($offset) {
     // Since the theme registry allows for theme hooks to be requested that
     // are not registered, just check the existence of the key in the registry.
@@ -420,15 +428,19 @@
     return $this->storage[$offset];
   }
 
-  public function set($cid, $data, $bin, $lock = TRUE) {
-    $lock_name = $cid . ':' . $bin;
+  public function set($data, $lock = TRUE) {
+    $lock_name = $this->cid . ':' . $this->bin;
     if (!$lock || lock_acquire($lock_name)) {
-      if ($cached = cache_get($cid, $this->bin)) {
+      if ($cached = cache_get($this->cid, $this->bin)) {
         // Use array merge instead of union so that filled in values in $data
         // overwrite empty values in the current cache.
         $data = array_merge($cached->data, $data);
       }
-      cache_set($cid, $data, $bin);
+	  else {
+	    $registry = $this->initializeRegistry();
+		$data = array_merge($registry, $data);
+	  }
+      cache_set($this->cid, $data, $this->bin);
       if ($lock) {
         lock_release($lock_name);
       }
