? foo.patch
? foo2.patch
? views-object-cache.patch
? views-pluggable-block.patch
? views-pluggable-block2.patch
Index: views.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views.info,v
retrieving revision 1.7
diff -u -p -r1.7 views.info
--- views.info	12 Aug 2007 06:52:14 -0000	1.7
+++ views.info	29 Aug 2009 11:22:03 -0000
@@ -2,4 +2,5 @@
 name = Views
 description = Create customized lists and queries from your database.
 package = Views
+dependencies[] = ctools
 core = 6.x
Index: views.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views.install,v
retrieving revision 1.46.2.6
diff -u -p -r1.46.2.6 views.install
--- views.install	4 Jun 2009 17:21:04 -0000	1.46.2.6
+++ views.install	29 Aug 2009 11:22:04 -0000
@@ -136,7 +136,6 @@ function views_schema_1() {
   $schema['cache_views_data']['description'] = 'Cache table for views to store pre-rendered queries, results, and display output.';
   $schema['cache_views_data']['fields']['serialized']['default'] = 1;
 
-
   $schema['views_object_cache'] = array(
     'description' => 'A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.',
     'fields' => array(
@@ -296,3 +295,18 @@ function views_update_6007() {
   }
   return $ret;
 }
+
+/**
+ * Remove views_object_cache table and move the data to ctools_object_cache.
+ */
+function views_update_6008(&$sandbox) {
+  $ret = array();
+  $caches = db_query_range("SELECT * FROM {views_object_cache}");
+  while ($item = db_fetch_object($caches)) {
+    db_query("INSERT INTO {ctools_object_cache} (sid, name, obj, updated, date) VALUES (%d, '%s', '%s', %d, '%s')",
+      $item->sid, $item->name, $item->obj, $item->updated, $item->date);
+  }
+  db_drop_table($ret, 'views_object_cache');
+  return $ret;
+}
+
Index: views_ui.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views_ui.module,v
retrieving revision 1.109
diff -u -p -r1.109 views_ui.module
--- views_ui.module	30 Jan 2009 00:56:01 -0000	1.109
+++ views_ui.module	29 Aug 2009 11:22:04 -0000
@@ -222,17 +222,16 @@ function views_ui_theme() {
  * load it.
  */
 function views_ui_cache_load($name) {
-  views_include('cache');
   views_include('view');
-  $view = views_object_cache_get('view', $name);
+  ctools_include('object-cache');
+  $view = ctools_object_cache_get('view', $name);
 
   if (empty($view)) {
     $view = views_get_view($name);
 
     if (!empty($view)) {
       // Check to see if someone else is already editing this view.
-      global $user;
-      $view->locked = db_fetch_object(db_query("SELECT s.uid, v.updated FROM {views_object_cache} v INNER JOIN {sessions}  s ON v.sid = s.sid WHERE s.sid != '%s' and v.name = '%s' and v.obj = 'view' ORDER BY v.updated ASC", session_id(), $view->name));
+      $view->locked = ctools_object_cache_test('view', $view->name);
     }
   }
 
@@ -245,10 +244,6 @@ function views_ui_cache_load($name) {
   }
 }
 
-function views_ui_check_lock($view) {
-
-}
-
 /**
  * Specialized cache function to add a flag to our view, include an appropriate
  * include, and cache more easily.
@@ -258,7 +253,7 @@ function views_ui_cache_set(&$view) {
     drupal_set_message(t('Changes cannot be made to a locked view.'), 'error');
     return;
   }
-  views_include('cache');
+  ctools_include('object-cache');
   $view->changed = TRUE; // let any future object know that this view has changed.
 
   // Unset handlers; we don't want to write these into the cache
@@ -269,7 +264,7 @@ function views_ui_cache_set(&$view) {
     unset($view->display[$id]->handler);
     unset($view->display[$id]->default_display);
   }
-  views_object_cache_set('view', $view->name, $view);
+  ctools_object_cache_set('view', $view->name, $view);
 }
 
 
Index: includes/admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/admin.inc,v
retrieving revision 1.154.2.6
diff -u -p -r1.154.2.6 admin.inc
--- includes/admin.inc	10 Jun 2009 22:02:26 -0000	1.154.2.6
+++ includes/admin.inc	29 Aug 2009 11:22:09 -0000
@@ -667,7 +667,7 @@ function views_ui_delete_confirm(&$form_
  */
 function views_ui_delete_confirm_submit(&$form, &$form_state) {
   $form_state['view']->delete();
-  views_object_cache_clear('view', $form_state['view']->name);
+  ctools_object_cache_clear('view', $form_state['view']->name);
   drupal_set_message(t('The view has been deleted.'));
   $form_state['redirect'] = 'admin/build/views';
 }
@@ -702,7 +702,7 @@ function views_ui_break_lock_confirm(&$f
  * Submit handler to break_lock a view.
  */
 function views_ui_break_lock_confirm_submit(&$form, &$form_state) {
-  db_query("DELETE FROM {views_object_cache} WHERE obj = 'view' AND name = '%s'", $form_state['view']->name);
+  ctools_object_cache_clear_all('view', $form_state['view']->name);
   $form_state['redirect'] = 'admin/build/views/edit/' . $form_state['view']->name;
   drupal_set_message(t('The lock has been broken and you may now edit this view.'));
 }
@@ -924,7 +924,7 @@ function views_ui_edit_view_form_submit(
   cache_clear_all();
 
   // Remove this view from cache so we can edit it properly.
-  views_object_cache_clear('view', $form_state['view']->name);
+  ctools_object_cache_clear('view', $form_state['view']->name);
 }
 
 /**
@@ -932,7 +932,7 @@ function views_ui_edit_view_form_submit(
  */
 function views_ui_edit_view_form_cancel($form, &$form_state) {
   // Remove this view from cache so edits will be lost.
-  views_object_cache_clear('view', $form_state['view']->name);
+  ctools_object_cache_clear('view', $form_state['view']->name);
   if (empty($form['view']->vid)) {
     // I seem to have to drupal_goto here because I can't get fapi to
     // honor the redirect target. Not sure what I screwed up here.
Index: includes/cache.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/cache.inc,v
retrieving revision 1.24.2.1
diff -u -p -r1.24.2.1 cache.inc
--- includes/cache.inc	1 Jun 2009 23:33:39 -0000	1.24.2.1
+++ includes/cache.inc	29 Aug 2009 11:22:10 -0000
@@ -178,93 +178,3 @@ function views_cache_get($cid, $use_lang
   return cache_get($cid, 'cache_views');
 }
 
-/**
- * @defgroup views_object_cache Non-volatile cache storage
- * @{
- * The non-volatile object cache is used to store an object while it is
- * being edited, so that we don't have to save until we're completely
- * done. The cache should be 'cleaned' on a regular basis, meaning to
- * remove old objects from the cache, but otherwise the data in this
- * cache must remain stable, as it includes unsaved changes.
- */
-
-/**
- * Get an object from the non-volatile Views cache.
- *
- * This function caches in memory as well, so that multiple calls to this
- * will not result in multiple database reads.
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the view (or other object) being stored.
- * @param $skip_cache
- *   Skip the memory cache, meaning this must be read from the db again.
- *
- * @return
- *   The data that was cached.
- */
-function views_object_cache_get($obj, $name, $skip_cache = FALSE) {
-  static $cache = array();
-  $key = "$obj:$name";
-  if ($skip_cache) {
-    unset($cache[$key]);
-  }
-
-  if (!array_key_exists($key, $cache)) {
-    $data = db_fetch_object(db_query("SELECT * FROM {views_object_cache} WHERE sid = '%s' AND obj = '%s' AND name = '%s'", session_id(), $obj, $name));
-    if ($data) {
-      $cache[$key] = unserialize($data->data);
-    }
-  }
-  return isset($cache[$key]) ? $cache[$key] : NULL;
-}
-
-/**
- * Store an object in the non-volatile Views cache.
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the view (or other object) being stored.
- * @param $cache
- *   The object to be cached. This will be serialized prior to writing.
- */
-function views_object_cache_set($obj, $name, $cache) {
-  views_object_cache_clear($obj, $name);
-  db_query("INSERT INTO {views_object_cache} (sid, obj, name, data, updated) VALUES ('%s', '%s', '%s', '%s', %d)", session_id(), $obj, $name, serialize($cache), time());
-}
-
-/**
- * Remove an object from the non-volatile Views cache
- *
- * @param $obj
- *   A 32 character or less string to define what kind of object is being
- *   stored; primarily this is used to prevent collisions.
- * @param $name
- *   The name of the view (or other object) being stored.
- */
-function views_object_cache_clear($obj, $name) {
-  db_query("DELETE FROM {views_object_cache} WHERE sid = '%s' AND obj = '%s' AND name = '%s'", session_id(), $obj, $name);
-}
-
-/**
- * Remove all objects in the object cache that are older than the
- * specified age.
- *
- * @param $age
- *   The minimum age of objects to remove, in seconds. For example, 86400 is
- *   one day. Defaults to 7 days.
- */
-function views_object_cache_clean($age = NULL) {
-  if (empty($age)) {
-    $age = 86400 * 7; // 7 days
-  }
-  db_query("DELETE FROM {views_object_cache} WHERE updated < %d", time() - $age);
-}
-
-/**
- * @}
- */
