Index: panels.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/panels/panels.install,v
retrieving revision 1.1.6.49
diff -u -r1.1.6.49 panels.install
--- panels.install	30 May 2008 19:15:24 -0000	1.1.6.49
+++ panels.install	1 Jun 2008 23:08:47 -0000
@@ -11,7 +11,7 @@
       db_query(<<<EOT
         CREATE TABLE {panels_page} (
           pid integer NOT NULL DEFAULT 0,
-          name varchar(255) UNIQUE,
+          name varchar(128) UNIQUE,
           did integer,
           title varchar(128),
           access varchar(128),
@@ -81,15 +81,15 @@
       db_query(<<<EOT
         CREATE TABLE {panels_object_cache} (
           sid varchar(64),
-          did integer,
-          obj varchar(255),
-          timestamp integer,
-          data text
+          obj varchar(64),
+          name varchar(128),
+          data bytea,
+          updated integer NOT NULL DEFAULT 0,
+          PRIMARY KEY (sid, obj, name),
         );
 EOT
       );
-      db_query("CREATE INDEX {panels_object_cache}_idx ON {panels_object_cache} (sid, obj, did);");
-      db_query("CREATE INDEX {panels_object_cache}_time_idx ON {panels_object_cache} (timestamp);");
+      db_query("CREATE INDEX {panels_object_cache}_time_idx ON {panels_object_cache} (updated);");
       break;
 
     case 'mysql':
@@ -97,7 +97,7 @@
       db_query(<<<EOT
         CREATE TABLE {panels_page} (
           pid int(10) NOT NULL DEFAULT 0 PRIMARY KEY,
-          name varchar(255) UNIQUE,
+          name varchar(128) UNIQUE,
           did int(10),
           title varchar(128),
           access varchar(128),
@@ -159,12 +159,12 @@
       db_query(<<<EOT
         CREATE TABLE {panels_object_cache} (
           sid varchar(64),
-          did integer,
-          obj varchar(255),
-          data longtext,
-          timestamp integer,
-          KEY (sid, obj, did),
-          KEY (timestamp)
+          obj varchar(64),
+          name varchar(128),
+          data blob,
+          updated int(11) unsigned NOT NULL DEFAULT 0,
+          PRIMARY KEY (sid, obj, name),
+          KEY (updated)
         ) /*!40100 DEFAULT CHARACTER SET utf8 */
 EOT
       );
@@ -592,3 +592,51 @@
   return $ret;
 }
 
+/**
+ * Change field definition of {panels_object_cache} to make it more generic.
+ */
+function panels_update_5219() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("TRUNCATE TABLE {panels_object_cache}");
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} DROP INDEX sid");
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} CHANGE did name varchar(128) AFTER obj");
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} MODIFY obj varchar(64)");
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} CHANGE timestamp updated int(11) unsigned NOT NULL DEFAULT 0");
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} MODIFY data blob");
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} ADD PRIMARY KEY (sid, obj, name)");
+      break;
+
+    case 'pgsql':
+      // Indizes are automatically dropped by db_change_column(). 
+      $ret[] = update_sql("TRUNCATE TABLE {panels_object_cache}");
+      db_change_column($ret, 'panels_object_cache', 'did', 'name', 'varchar(128)');
+      db_change_column($ret, 'panels_object_cache', 'obj', 'obj', 'varchar(64)');
+      db_change_column($ret, 'panels_object_cache', 'timestamp', 'updated', 'int(11)', array('NOT NULL' => TRUE, 'DEFAULT => 0'));
+      $ret[] = update_sql("ALTER TABLE {panels_object_cache} ADD PRIMARY KEY (sid, obj, name)");
+      $ret[] = update_sql("CREATE INDEX {panels_object_cache}_time_idx ON {panels_object_cache} (updated);");
+  }
+  return $ret;
+}
+
+/**
+ * Downsize {panels_page}.name to 128 chars.
+ * 
+ * Followup to panels_update_5219() to improve performance and consistency.
+ */
+function panels_update_5220() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {panels_page} MODIFY name varchar(128)");     
+      break;
+
+    case 'pgsql':
+      db_change_column($ret, 'panels_page', 'name', 'name', 'varchar(128)');
+  }
+  }
+  return $ret;
+}
Index: panels.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/panels/panels.module,v
retrieving revision 1.10.4.106
diff -u -r1.10.4.106 panels.module
--- panels.module	30 May 2008 00:23:09 -0000	1.10.4.106
+++ panels.module	1 Jun 2008 23:08:47 -0000
@@ -285,45 +285,75 @@
 }
 
 // ---------------------------------------------------------------------------
-// cache handling stuff for display editing
+// Cache handling for display objects.
 
 /**
- * Get a display from the cache; this is used if the display is currently
- * being edited, which can be a seriously multi-step process.
+ * Get a display object from the cache.
+ *
+ * This is used while editing a display, which can be a multi-step process.
+ *
+ * @param integer $did
+ *  Display ID.
+ * @return object
+ *  The display object to be retrieved.
  */
 function panels_cache_get($did) {
-  return panels_common_cache_get('panels', $did);
+  return panels_common_cache_get('display_object', $did);
 }
 
 /**
- * Save the edited display into the cache.
+ * Save a display object into the cache.
+ *
+ * This is used while editing a display, which can be a multi-step process.
+ *
+ * @param integer $did
+ *  Display ID.
+ * @param object $data
+ *  The display object to be cached.
  */
-function panels_cache_set($did, $cache) {
-  return panels_common_cache_set('panels', $did, $cache);
+function panels_cache_set($did, $data) {
+  return panels_common_cache_set('display_object', $did, $data);
 }
 
 /**
- * Clear a display from the cache; used if the editing is aborted.
+ * Clear a display from the cache.
+ * 
+ * This is used when editing a display is aborted.
+ *
+ * @param integer $did
+ *  Display ID.
  */
 function panels_cache_clear($did) {
-  return panels_common_cache_clear('panels', $did);
+  return panels_common_cache_clear('display_object', $did);
 }
 
 // ---------------------------------------------------------------------------
-// cache handling stuff for non-display objects.
+// Generic cache handling for non-display objects.
 
 /**
- * Get an object from cache.
+ * Get an object from the cache.
+ *
+ * If you want to get a display object to the cache, please use the more
+ * specialized shortcut function panels_cache_get() instead.
+ * 
+ * @param string $obj
+ *  The string representing the object's type.
+ * @param varchar $name
+ *  The object's identifier. May be a name or a numeric ID.
+ * @param boolean $skip_cache
+ *  (optional) Switch to skip the cache. Defaults to FALSE.
+ * @return object
+ *  The object to be retrieved.
  */
-function panels_common_cache_get($obj, $did, $skip_cache = FALSE) {
+function panels_common_cache_get($obj, $name, $skip_cache = FALSE) {
   static $cache = array();
-  $key = "$obj:$did";
+  $key = "$obj:$name";
   if ($skip_cache) {
     unset($cache[$key]);
   }
 
   if (!array_key_exists($key, $cache)) {
-    $data = db_fetch_object(db_query("SELECT * FROM {panels_object_cache} WHERE sid = '%s' AND obj = '%s' AND did = %d", session_id(), $obj, $did));
+    $data = db_fetch_object(db_query("SELECT * FROM {panels_object_cache} WHERE sid = '%s' AND obj = '%s' AND name = '%s'", session_id(), $obj, $name));
     if ($data) {
       $cache[$key] = unserialize($data->data);
     }
@@ -332,18 +362,37 @@
 }
 
 /**
- * Save the edited display into the cache.
- */
-function panels_common_cache_set($obj, $did, $cache) {
-  panels_common_cache_clear($obj, $did);
-  db_query("INSERT INTO {panels_object_cache} (sid, obj, did, data, timestamp) VALUES ('%s', '%s', %d, '%s', %d)", session_id(), $obj, $did, serialize($cache), time());
+ * Save an object into the cache.
+ * 
+ * If you want to save a display object to the cache, please use the more
+ * specialized shortcut function panels_cache_set() instead.
+ * 
+ * @param string $obj
+ *  A string representing the object's type (max. 64 characters).
+ * @param varchar $name
+ *  The object's identifier.
+ *  May be a name (max. 128 characters) or a numeric ID.
+ * @param object $data
+ *  The object to be cached.
+ */
+function panels_common_cache_set($obj, $name, $data) {
+  panels_common_cache_clear($obj, $name);
+  db_query("INSERT INTO {panels_object_cache} (sid, obj, name, data, updated) VALUES ('%s', '%s', '%s', '%s', %d)", session_id(), $obj, $name, serialize($data), time());
 }
 
 /**
- * Clear a display from the cache; used if the editing is aborted.
+ * Clear an object from the cache.
+ * 
+ * If you want to clear a display object from the cache, please use the more
+ * specialized shortcut function panels_cache_clear() instead.
+ * 
+ * @param string $obj
+ *  The string representing the object's type and owner.
+ * @param varchar $name
+ *  The object's identifier. May be a name or a numeric ID.
  */
 function panels_common_cache_clear($obj, $did) {
-  db_query("DELETE FROM {panels_object_cache} WHERE sid = '%s' AND obj = '%s' AND did = %d", session_id(), $obj, $did);
+  db_query("DELETE FROM {panels_object_cache} WHERE sid = '%s' AND obj = '%s' AND name = '%s'", session_id(), $obj, $name);
 }
 
 /**
@@ -351,7 +400,7 @@
  */
 function panels_cron() {
   // delete anything 7 days old or more.
-  db_query("DELETE FROM {panels_object_cache} WHERE timestamp < %d", time() - (86400 * 7));
+  db_query("DELETE FROM {panels_object_cache} WHERE changed < %d", time() - (86400 * 7));
 }
 
 /**
Index: panels_mini/panels_mini.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/panels/panels_mini/Attic/panels_mini.install,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 panels_mini.install
--- panels_mini/panels_mini.install	27 May 2008 20:21:14 -0000	1.1.2.6
+++ panels_mini/panels_mini.install	1 Jun 2008 23:08:47 -0000
@@ -11,7 +11,7 @@
       db_query(<<<EOT
         CREATE TABLE {panels_mini} (
           pid integer NOT NULL DEFAULT 0,
-          name varchar(255) UNIQUE,
+          name varchar(128) UNIQUE,
           did integer,
           title varchar(128),
           requiredcontexts text,
@@ -30,7 +30,7 @@
       db_query(<<<EOT
         CREATE TABLE {panels_mini} (
           pid int(10) NOT NULL DEFAULT 0 PRIMARY KEY,
-          name varchar(255) UNIQUE,
+          name varchar(128) UNIQUE,
           did int(10),
           title varchar(128),
           contexts longtext,
@@ -139,3 +139,21 @@
   return $ret;
 }
 
+/**
+ * Downsize {panels_page}.name to 128 chars.
+ * 
+ * Followup to panels_update_5219() to improve performance and consistency.
+ */
+function panels_mini_update_5002() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {panels_mini} MODIFY name varchar(128)");     
+      break;
+
+    case 'pgsql':
+      db_change_column($ret, 'panels_page', 'name', 'name', 'varchar(128)');
+    }
+  return $ret;
+}
Index: panels_mini/panels_mini.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/panels/panels_mini/Attic/panels_mini.module,v
retrieving revision 1.1.2.28
diff -u -r1.1.2.28 panels_mini.module
--- panels_mini/panels_mini.module	29 May 2008 23:32:10 -0000	1.1.2.28
+++ panels_mini/panels_mini.module	1 Jun 2008 23:08:48 -0000
@@ -485,6 +485,7 @@
   $form['left']['settings']['name'] = array(
     '#type' => 'textfield',
     '#size' => 24,
+    '#maxlength' => 128,
     '#default_value' => $panel_mini->name,
     '#title' => t('Mini panel name'),
     '#description' => t('A unique name used to identify this panel page internally. It must be only be alpha characters and underscores. No spaces, numbers or uppercase characters.'),
Index: panels_page/panels_page.admin.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/panels/panels_page/Attic/panels_page.admin.inc,v
retrieving revision 1.1.2.47
diff -u -r1.1.2.47 panels_page.admin.inc
--- panels_page/panels_page.admin.inc	29 May 2008 23:17:57 -0000	1.1.2.47
+++ panels_page/panels_page.admin.inc	1 Jun 2008 23:08:48 -0000
@@ -276,6 +276,7 @@
   $form['left']['info']['name'] = array(
     '#type' => 'textfield',
     '#size' => 35,
+    '#maxlength' => 128,
     '#default_value' => $panel_page->name,
     '#title' => t('Panel name'),
     '#description' => t('A unique name used to identify this panel page internally. It must be only be alpha characters and underscores. No spaces, numbers or uppercase characters.'),
