Kind of a bug, more of a warning.

Just a heads-up regarding the length of plugin names and the Export UI.

If you are using the default Export UI handler class and its associated functions, then your plugin name must be less than 27 characters long. Otherwise import validation will not work.

The reason for this is that cached ctools objects can not be retrieved for plugins with long names. The 'name' field in the 'ctools_object_cache' table is only 32 chars long. (See ctools/inc/object-cache.inc, L42). During an import process an entry is made in the 'ctools_object_cache' table for the item being imported. This entry is keyed by both the 'import' operation ('::import') and the import object name ('ctui_' + the plugin name).

When the plugin name is longer than 27 characters problems occur. The import object name exceeds the size of the 'object' field in the 'ctools_object_cache' table, and it is truncated to 32 characters. When ctools tries to retrieve the corresponding cache object, it queries with the *full* import object name. Because the full name does not match the truncated name, the query returns no results and the cache object is not retrieved.

This can cause problems with validation during the import process.

Possible fixes:

* Make the 'object' field in the 'ctools_object_cache' table longer to accommodate longer plugin names

* Make the db_query in ctools/inc/object-cache.inc: ctools_object_cache_get truncate the object name to match the db

* Put a note in the export_ui documentation (which overall is excellent by the way) about the plugin name length limit.

I can't say enough how useful CTools is. I love your work!

Comments

merlinofchaos’s picture

I think making the object cache name field longer is probably best. 27 is a reasonable length but I can see overshooting that pretty easily.

Even so, there's still going to be a length limit, so we should document whatever that ends up being at the same time.

vgoodvin’s picture

Hi.

I have this problem with my custom module. Also some contrib modules may have a broken importing functionality. For example http://drupal.org/project/ffmpeg_converter

I attached my patch, that just updates the 'obj' field.

Thanks.

andypost’s picture

Status: Active » Needs work

Suppose patch should be against 7.x and then backported to 6.x

+++ b/ctools.installundefined
@@ -73,6 +73,9 @@ function ctools_schema_2() {
+  $schema['ctools_object_cache']['fields']['obj']['length'] = 128;

I think 64 is enough for object

+++ b/ctools.installundefined
@@ -228,4 +231,17 @@ function ctools_update_6007() {
+ * Enlarge the ctools_object_cache.obj column to prevent truncation and weird
+ * errors.

First code comment should be 1 line

Powered by Dreditor.

vgoodvin’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review

Thanks. I attached patch for 7.x with corrections.

vgoodvin’s picture

merlinofchaos’s picture

Status: Needs review » Needs work

schema_2 is locked. We need to create a schema_3 and update. It's how i track changes in tables to make it theoretically easier to manage. (I'm not sure that theory has actually worked out in practice).

geek-merlin’s picture

Just for reference: The current API states that 'obj' limit is 128. Let's use that so we don't have a followup doc issue.

/**
 * Store an object in the non-volatile ctools cache.
 *
 * @param $obj
 *   A 128 character or less string to define what kind of object is being
 *   stored; primarily this is used to prevent collisions.
…
 */
function ctools_object_cache_set($obj, $name, $cache, $sid = NULL) {
…
}
rooby’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

New version with changes from #6 & #7

Stevel’s picture

Status: Needs review » Reviewed & tested by the community

This patch makes the environment indicator import work, so marking this as RTBC.

Stevel’s picture

Issue tags: +Needs documentation

Added tag.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: ctools-plugin_name_field_size-1058786-8.patch, failed testing.

Stevel’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

There was a line changed just above the changes in this patch (the comment in the first line of the patch). Reroll should be good to go.

azinck’s picture

Status: Needs review » Reviewed & tested by the community

This issue causes a PDOException on SQL Server. The patch fixes the problem for now. Should we consider something less fragile (like hashing)?

  • japerry committed d9634d1 on 7.x-1.x authored by vgoodvin
    Issue #1058786 by vgoodvin, Stevel, rooby: Caveat About Plugin Name...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Reviewed and merged against dev. Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.