If the machine-readable name of a feature is too long, the files exported in the tarball have truncated names, which causes the features module to not find the files when loading the feature.

For example, I created a feature based on a content type that had an auto-generated machine-readable name of 'project_business_requirements_questionnaire'. When I loaded the feature to another instance of Drupal, the content type was created, but none of the fields or field groups were in the content type. I discovered that the *.features.content.inc and *.features.fieldgroup.inc in the tarball had been truncated to 'project_business_requirements_questionnaire.features.con' and 'project_business_requirements_questionnaire.features.fie'. When the feature was loaded, the code did not find the files since they were not named according to the naming standard, and the fields and field groups did not load.

To correct this, the interface could limit the length of the machine-readable name, or the files need to be created with the full file name.

Comments

shawn_smiley’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Component: User interface » Code
Priority: Normal » Major

I can confirm that this also happens in D7 with exporting a custom panel layout template file that I'm including in the feature (path: longmodulename/plugins/layouts/longmodulename_home/longmodulename-home-longmodulename-home.tpl.php).

I've traced the problem to the following code in features.export.inc, line 382 (Drupal 7 dev version):

function features_tar_create($name, $contents) {
  $tar = '';
  $binary_data_first = pack("a100a8a8a8a12A12",
    $name,
    '100644 ', // File permissions
    '   765 ', // UID,
    '   765 ', // GID,
    sprintf("%11s ", decoct(strlen($contents))), // Filesize,
    sprintf("%11s", decoct(REQUEST_TIME)) // Creation time
  );

In particular, the pack() command which appears to limit the length of the first attribute ($name) to 100 characters.

The important thing here is that the $name parameter is the full path from the root of the module to the file. This full path must be at most 100 characters.

I'm not familiar enough with the pack() command to know what the potential implications are of changing the maximum length. I did a quick test of changing it to 128 and it didn't seem to cause any problems.

The updated code that supports paths with up to 128 characters is:

  $binary_data_first = pack("a128a8a8a8a12A12",
    $name,
    '100644 ', // File permissions
    '   765 ', // UID,
    '   765 ', // GID,
    sprintf("%11s ", decoct(strlen($contents))), // Filesize,
    sprintf("%11s", decoct(REQUEST_TIME)) // Creation time
  );
czigor’s picture

The above hack renders the downloaded tarball corrupt for me.

DanielFird’s picture

I have been suffering from accessing, managing and even renaming files that have more than 255 characters over a long time. I have tried various ways but failed. Then I have searched this problem in internet. Then I have found a solution. This software is very easy to use. Named Long path Tool. To use the program all you need to do is to download this program online and save all the settings to your computer. This program is compatible with Windows NT, 2000, XP, Vista and Windows 7. you can find it from longpathtool(dot)com.

Grayside’s picture

255 is also a drupal database limitation, as I recall.

mpotter’s picture

Status: Active » Closed (won't fix)

As per http://en.wikipedia.org/wiki/Tar_(file_format) the name field in a tar file is limited 100 characters. There are other file formats that get around this, but since we are using tar, we are stuck with this.

lpalgarvio’s picture

suggesting a form validation. on form submit? javascript if not i guess...
#1664298: Form validation

lpalgarvio’s picture

Status: Closed (won't fix) » Closed (duplicate)